feat: add --remote-repo-url to "iac test" #3453
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR do?
This PR adds support for the
--remote-repo-url
flag to theiac test
command. The flag can be used by a user to override the URL of the Git repository, that is otherwise auto-detected by the command.Where should the reviewer start?
Most of the logic is in
src/cli/commands/test/iac/scan.ts
. The change in this PR creates anIacOutputMeta
object at the beginning of the scan and passes it down to the components that need the information in it. Previously, theIacOutputMeta
was constructed by the individual components, and surfaced up the stack. Because theIacOutputMeta
is not dependent on the paths being scanned, it can be constructed once from a combination of flag values and auto-detected information (like the name of the current working directory and the URL of the Git repository, if any).How should this be manually tested?
Use different combinations of current working directory and flags:
snyk iac test --report
creates a project group whose name is the name of the current working directory.snyk iac test --report
creates a project group whose name is derived from the URL of the Git repository, in the same way as the examples below.snyk iac test --report --remote-repo-url=foo/bar
creates a project group whose name isfoo/bar
.snyk iac test --report --remote-repo-url=https://example.com/foo/bar.git
creates a project group whose name isfoo/bar
.snyk iac test --report --remote-repo-url=git@example.com:foo/bar.git
creates a project group whose name isfoo/bar
.The summary section will always return the correct project name. For example,
What are the relevant tickets?
CFG-1842