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

Fail 'jf scan' when a wrong flag is provided after command's arguments #165

Open
wants to merge 12 commits into
base: dev
Choose a base branch
from

Conversation

eranturgeman
Copy link
Contributor

@eranturgeman eranturgeman commented Sep 3, 2024

  • The pull request is targeting the dev branch.
  • The code has been validated to compile successfully by running go vet ./....
  • The code has been formatted properly using go fmt ./....
  • All static analysis checks passed.
  • All tests have passed. If this feature is not already covered by the tests, new tests have been added.
  • All changes are detailed at the description. if not already covered at JFrog Documentation, new documentation have been added.

The 'jf scan' command should be executed in the following manner: jf scan [command options] OR jf scan [command options] --spec=.
If the command was written in a different order: jf scan [command options], it may lead that some flags are mistaken as arguments and are not going through the command's flags verifications. Therefore, if a wrong flag was provided in this manner - it will get skipped completely without informing the customer.
I added a warning to indicate the wrong usage and what it may cause.
The indication comes in a Warning form and not error in order to not breaking customers.

…with arguments that have been provided in an incorrect order
@eranturgeman eranturgeman added ignore for release Automatically generated release notes safe to test Approve running integration tests on a pull request labels Sep 3, 2024
@github-actions github-actions bot removed the safe to test Approve running integration tests on a pull request label Sep 3, 2024
@eranturgeman eranturgeman added the safe to test Approve running integration tests on a pull request label Sep 3, 2024
@github-actions github-actions bot removed the safe to test Approve running integration tests on a pull request label Sep 3, 2024
Copy link
Contributor

@attiasas attiasas left a comment

Choose a reason for hiding this comment

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

Nice, take a look at my comments

utils/utils.go Outdated Show resolved Hide resolved
cli/scancommands.go Outdated Show resolved Hide resolved
@eranturgeman eranturgeman added the safe to test Approve running integration tests on a pull request label Sep 5, 2024
@github-actions github-actions bot removed the safe to test Approve running integration tests on a pull request label Sep 5, 2024
@@ -196,7 +196,13 @@ func EnrichCmd(c *components.Context) error {
func ScanCmd(c *components.Context) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

does docker scan uses the same flow as ScanCmd? or should implement it there too?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, it is using dockerCmd that resides in CLI. I initiated another PR to ecosystem:
jfrog/jfrog-cli#2686

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@hadarshjfrog Since resolving the same issue in 'jf docker scan' should be done by Ecosystem and this is not a top priority for them. Since this is not going to happen soon and I dont want to miss the fix Iv'e already worked on im proceeding without 'jf docker scan' and we can open a ticket for the Ecosystem about this

@hadarshjfrog
Copy link
Contributor

Please add integration tests you think might simulate it - with the common mistakes we have seen (flags at the end instead of beginning, watch/license instead of watches/licenses

@eranturgeman eranturgeman changed the title Add a warning to indicate wrong usage in 'jf scan' command Fail 'jf scan' when a wrong flag is provided after command's arguments Sep 5, 2024
@eranturgeman eranturgeman added bug Something isn't working safe to test Approve running integration tests on a pull request and removed ignore for release Automatically generated release notes labels Nov 11, 2024
@github-actions github-actions bot removed the safe to test Approve running integration tests on a pull request label Nov 11, 2024
Copy link

👍 Frogbot scanned this pull request and did not find any new security issues.


Copy link

Merging this branch will not change overall coverage

Impacted Packages Coverage Δ 🤖
github.com/jfrog/jfrog-cli-security 0.00% (ø)
github.com/jfrog/jfrog-cli-security/cli 0.00% (ø)
github.com/jfrog/jfrog-cli-security/utils 0.00% (ø)

Coverage by file

Changed files (no unit tests)

Changed File Coverage Δ Total Covered Missed 🤖
github.com/jfrog/jfrog-cli-security/cli/scancommands.go 0.00% (ø) 0 0 0
github.com/jfrog/jfrog-cli-security/utils/utils.go 0.00% (ø) 0 0 0

Please note that the "Total", "Covered", and "Missed" counts above refer to code statements instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code.

Changed unit test files

  • github.com/jfrog/jfrog-cli-security/scans_test.go

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants