Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add --remote-repo-url to "iac test" #3453

Merged
merged 1 commit into from
Jul 14, 2022

Conversation

francescomari
Copy link
Contributor

What does this PR do?

This PR adds support for the --remote-repo-url flag to the iac 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 an IacOutputMeta object at the beginning of the scan and passes it down to the components that need the information in it. Previously, the IacOutputMeta was constructed by the individual components, and surfaced up the stack. Because the IacOutputMeta 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:

  • If the current working directory is not a Git repository snyk iac test --report creates a project group whose name is the name of the current working directory.
  • If the current working directory is a Git repository, 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 is foo/bar.
  • snyk iac test --report --remote-repo-url=https://example.com/foo/bar.git creates a project group whose name is foo/bar.
  • snyk iac test --report --remote-repo-url=git@example.com:foo/bar.git creates a project group whose name is foo/bar.

The summary section will always return the correct project name. For example,

Report Complete

  Your test results are available at: https://dev.snyk.io/org/francescomari/projects
  under the name: foo/bar

What are the relevant tickets?

CFG-1842

@francescomari francescomari marked this pull request as ready for review July 12, 2022 11:45
@francescomari francescomari requested review from a team as code owners July 12, 2022 11:45
@francescomari francescomari force-pushed the feat/iac-test-add-remote-repo-url-flag branch 2 times, most recently from cf43973 to 371d827 Compare July 13, 2022 07:36
@ipapast
Copy link
Contributor

ipapast commented Jul 13, 2022

we also discussed on slack to check that we do some sanitisation on registry side for the remote url string. So probably merging this after any registry changes.

package.json Outdated Show resolved Hide resolved
Copy link
Contributor

@Avishagp Avishagp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blocking as Hammer refrains from adding new dependencies to the CLI unless totally needed. We think it's not a must here, and would prefer no new dependency is introduced

@francescomari francescomari force-pushed the feat/iac-test-add-remote-repo-url-flag branch from 371d827 to c804c5a Compare July 13, 2022 18:08
@francescomari francescomari force-pushed the feat/iac-test-add-remote-repo-url-flag branch from c804c5a to 2a12048 Compare July 13, 2022 18:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants