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

SBOM Tool returns exit code 0 even if the arguments are invalid #593

Closed
gustavoaca1997 opened this issue Jun 12, 2024 · 3 comments
Closed

Comments

@gustavoaca1997
Copy link
Contributor

How to repro:

Use a BuildDropPath that includes a white space, without enclosing it in quotes, something like this:

sbom-tool-win-x64.exe validate /BuildDropPath:C:\Users\gustavoca\ABC DEF\12094507251016833242-TestDirectory /OutputPath:C:\Users\gustavoca\OutputFolder\aa34e9e20cf448499f082eec1578f24c.json /mi:SPDX:2.2 /verbosity:Verbose

will make the tool output this error:

Unexpected argument: DEF\12094507251016833242-TestDirectory

The Sbom tool generates a SBOM for any build artifact.

Usage - Microsoft.Sbom.Tool <action> -options

GlobalOption    Description
Help (-?, -h)   Prints this help message
...

but the exit code will be 0:

>echo $LASTEXITCODE
0
@jlperkins jlperkins added the needs triage Default status upon issue submission label Jun 12, 2024
@DaveTryon DaveTryon removed the needs triage Default status upon issue submission label Jun 13, 2024
@DaveTryon
Copy link
Contributor

@gustavoaca1997, I suspect you may be using an old version of the tool. I tried your repro case on the current version and the return code is 1, not 0. #520 reported a problem with return codes, which was fixed in #544, and the fix should be in current version (2.2.6) on Nuget

As a side note, this tool requires a - instead of a / for the arguments and expects a space between the parameter name and the parameter value. As a result, your command line would fail, even if it there were no spaces in your paths. Please refer to these docs for some specific examples of how to structure your command line.

@gustavoaca1997
Copy link
Contributor Author

Thank you for the reply @DaveTryon . I am indeed using an older version (2.2.3).

Regarding using - instead of /, we are currently using /, and it's working fine. Would updating to 2.2.6 break calls that are using /?

@DaveTryon
Copy link
Contributor

@gustavoaca1997, I hadn't realized that PowerArgs supported the / syntax, but that's listed in their readme. Our tool uses the same version of PowerArgs in 2.2.3 and 2.2.6, so I wouldn't expect this to be a breaking change for you.

I'll go ahead and close out this issue, since the originally reported problem has already been addressed. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants