fix: pass in folderConfig to scans, instead of deriving it. Ensures correct org is used for file scans [IDE-1671]#1119
Conversation
…orrect org is used for file scans
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
Summary of ChangesHello @andrewrobinsonhodges-snyk, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a significant refactoring to standardize how scan configurations, particularly organizational settings, are passed to and utilized by Snyk's various product scanners (Code, IaC, and Open Source). By modifying the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request refactors the scanning mechanism to pass a folderConfig object to scan functions instead of deriving it from a folder path. This is a good change that makes dependencies more explicit and aims to fix an issue with organization resolution for file scans. The changes are applied consistently across interfaces, implementations, and tests.
I've found a critical issue in domain/snyk/scanner/base_scan.go where the refactoring breaks base branch scanning for Snyk Code by causing it to scan the wrong directory. I've provided a detailed comment and a code suggestion to fix this. Other than that, the changes look solid.
…narios [IDE-1671] Add unit tests for base_scan.go delta scan logic: - Test all products receive correct path and folderConfig - Test Code scanner receives empty path for folder scans - Test OSS/IaC scanners receive baseFolderPath as path - Test original folderConfig is preserved (not modified) - Test nil folderConfig returns error - Test scan is skipped when snapshot exists - Test all products use correct org from folderConfig Add file, subfolder, and workspace scan tests for OSS: - Test file scan uses folderConfig organization - Test subfolder scan uses folderConfig organization - Test workspace folder scan uses folderConfig organization - Test delta scan base branch uses correct folderConfig Add file, subfolder, and workspace scan tests for IaC: - Test file scan uses folderConfig organization - Test subfolder scan uses folderConfig organization - Test workspace folder scan uses folderConfig organization - Test delta scan base branch uses correct folderConfig
|
still in draft - is this intentional? |
|
also out of date with base branch :) |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
PR Reviewer Guide 🔍
|
Before we had per-folder config, we used to pass in a file path and a folder path to OSS, Code and IaC scanners. The original intention was that the file path represented the file or folder to be scanned, and the folder path was used for context (i.e. which workspace are we using).
Over time this became inconsistent between the scanners, with some using the folder path for the scan target. Now that we have FolderConfigs for LDX-Sync, we can simplify this.
The path parameter is the thing to be scanned; either a single file or a folder, which may or may not be the top level of the Workspace.
The FolderConfig contains the workspace for which we should use the scan configuration (e.g, which org to use etc.).
This means that scanning files and folders should now always use the correct org, and be consistent across IaC, OSS and Code.
Description
Provide description of this PR and changes, if linked Jira ticket doesn't cover it in full.
Checklist
make generate)make lint-fix)