Checkmarx / ast-cli

A CLI project wrapping application security testing (AST) APIs
Apache License 2.0
41 stars 26 forks source link

Remove from system sca json file when using scan create with scaResolver (AST-48074) #922

Closed Korjen97 closed 3 days ago

Korjen97 commented 1 week ago

…lver

By submitting a PR to this repository, you agree to the terms within the Checkmarx Code of Conduct. Please see the contributing guidelines for how to create and submit a high-quality PR for this repo.

Description

File Removal Logic: Added _ = os.Remove(scaFile.Name()) at the end of the function to ensure the temporary file created by ioutil.TempFile is deleted after the scan completes.

References

https://checkmarx.atlassian.net/browse/AST-48074

Testing

Unit Test (TestRunScaResolverFileCleanup) Mock Setup: Defined mock values for sourceDir, scaResolver, and projectName. Function Execution: Called runScaResolver with the mock inputs. File Deletion Check: Verified that the temporary file was deleted using os.Stat and os.IsNotExist, ensuring that the cleanup process worked as expected.

Please include any manual steps for testing end-to-end or functionality not covered by unit/integration tests.

Checklist