Quack Patch enhancements#1763
Conversation
| if (propertyConfiguration.getValueOrDefault(DetectProperties.DETECT_QUACK_PATCH_ENABLED)) { | ||
| String quackPatchOutputDirPath = propertyConfiguration.getValueOrDefault(DetectProperties.DETECT_QUACK_PATCH_OUTPUT); | ||
| // If quack patch output path is customized, then explicitly include it in the diagnostic zip. Otherwise, default behaviour will automatically pack it. | ||
| if (!quackPatchOutputDirPath.isEmpty()) { | ||
| quackPatchOutputDirPath = quackPatchOutputDirPath + File.separator + QUACKPATCH_SUBDIRECTORY_NAME; | ||
| logger.info("Adding quack patch output dir {} to the diagnostic zip.", quackPatchOutputDirPath); | ||
| // Copy directory quackPatchOutputDirPath to directoryManager.getRunsOutputDirectory() | ||
| try { | ||
| FileUtils.copyDirectory(new File(quackPatchOutputDirPath), new File(directoryManager.getScanOutputDirectory().getAbsolutePath() + File.separator + QUACKPATCH_SUBDIRECTORY_NAME)); | ||
| } catch (IOException e) { | ||
| logger.error("Failed to copy quack patch output directory to runs directory. Error: {}", e.getMessage()); | ||
| return false; | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
If quack patch output path is not set, output will be written to runs/<timestamp-dir>/scan folder and diagnostics will have that information by default. If the output path is customized, then copying that directory into runs/<timestamp-dir>/scan folder so that diagnostics process can pick it up as default.
Note: Diagnostics archive process was adding the files based on its path. If the target file is outside runs dir context, compress logic is trying to add it as a relative path (e.g. runs/../../quack-patch/***). Copying quack-patch files into scan would keep the behaviour consistent.
| private boolean createZip() { | ||
| // If quack patch is enabled, then add quack patch output directory to the zip | ||
| if (propertyConfiguration.getValueOrDefault(DetectProperties.DETECT_QUACK_PATCH_ENABLED)) { | ||
| String quackPatchOutputDirPath = propertyConfiguration.getValueOrDefault(DetectProperties.DETECT_QUACK_PATCH_OUTPUT); |
There was a problem hiding this comment.
Unable to use the helper function (getQuackPatchOutputDirectory from detectConfigurationFactory) to get the quack patch output path here due to missing config context. Hence, the duplication of code.
Description
Changes,
Github Issues
IDETECT-5121, IDETECT-5140