View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0035039 | mantisbt | reports | public | 2024-11-26 13:48 | 2025-03-01 18:40 |
Reporter | raspopov | Assigned To | dregad | ||
Priority | normal | Severity | minor | Reproducibility | always |
Status | closed | Resolution | fixed | ||
Product Version | 2.27.0 | ||||
Target Version | 2.27.1 | Fixed in Version | 2.27.1 | ||
Summary | 0035039: The GraphViz tool is almost impossible to customise for Windows | ||||
Description | Setting the $g_graphviz_path option to 'C:\Program Files\Graphviz\bin\' will not work due to un-escaped spaces in the path and incorrectly escaped directory delimiter slashes in the proc_open() call at "core\graphviz_api.php". | ||||
Tags | No tags attached. | ||||
The escapeshellcmd() call that is being removed in the proposed PR, was added as part of 0026091 to fix a security issue, so I'm reluctant to remove it, even though it is unlikely that this could be used as an attack vector since $g_graphviz_path can only be altered via changes in config_inc.php. Since PHP 7.4, the command executed in proc_open() can be given as an array; according to the documentation In this case the process will be opened directly (without going through a shell) and PHP will take care of any necessary argument escaping, so maybe a better solution would be
I do not have a Windows environment to test this on, maybe you can confirm ? I will test on Linux later. |
|
I had the issue a few months ago. After a tip from atrol I just placed it directly on C: and then set $g_dot_tool = 'C:\Graphviz\bin\dot.exe'; In the config. I don't have $g_graphviz_path in my config. Perhaps you could do the same? |
|
Since 2.27.0, these 2 configs have been obsoleted, and are no longer used anywhere in the codebase. You can remove them from your config...
The path to the tools is built dynamically from $g_graphviz_path (default value is |
|
Probably:
|
|
@degrad I'm currently still on 2.62.2, but thx but the heads-up this has been changed. The space in in the original path (I had Program Files first to) was the problem for me. Thats why @atrol suggested to place it directly on C: so there are no spaces in the path. I left it there bc our server is dedicated for mantisbt. |
|
OK that explains it. Thanks for the feedback @diedie2. |
|
Unfortunately it doesn't work that way on Windows, plus it requires PHP 7.4.0. I doubt that the escapeshellcmd() function is needed at all in this case, because there is code above that checks the program path for validity by is_executable(). I have tried many options over many hours and the best one is this, it also does the correct masking of spaces:
I have refreshed PR. |
|
In the PR I also added realpath() for Graphviz tools it efficiently fixes any problems with path including wrong directory separators and missing trailing separator. |
|
So you're saying that this standard PHP syntax does not work on Windows ? The manual states that command may be passed as array of command parameters. In this case the process will be opened directly (without going through a shell) and PHP will take care of any necessary argument escaping.. I must admit I do not fully understand what the following note implies: On Windows, the argument escaping of the array elements assumes that the command line parsing of the executed command is compatible with the parsing of command line arguments done by the VC runtime.
Indeed, but this is the minimum required version to run MantisBT, so no problem here. |
|
I'm not quite sure but I suspect it does the same thing as escapeshellcmd() but internally so no error returns and result is empty, I also monitored file openings with Process Monitor (by Mark Russinovich) and saw no attempt to open or execute any file with good or bad paths. Maybe it depends on the Apache or PHP configuration. |
|
MantisBT: master-2.27 a6e8c5c7 2024-11-26 13:51 Committer: dregad Details Diff |
Fix Graphviz calls on Windows Failing due to unescaped spaces in the path and incorrectly escaped directory delimiter slashes in the proc_open() call. Use realpath() to set the path to the library, and add escapeshellarg() in the Graphviz tool call. Fixes 0035039 Signed-off-by: Damien Regad <dregad@mantisbt.org> Original commits squashed. |
Affected Issues 0035039 |
|
mod - admin/check/check_display_inc.php | Diff File | ||
mod - core/graphviz_api.php | Diff File | ||
MantisBT: master-2.27 b84319e7 2024-12-09 10:49 Committer: dregad Details Diff |
New Graph::graphviz_path() function avoids duplicate code Issue 0035039 |
Affected Issues 0035039 |
|
mod - admin/check/check_display_inc.php | Diff File | ||
mod - core/graphviz_api.php | Diff File |