test: resolve bugs in sourcecode analyzer to allow unit tests to run offline #1136
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.
Summary
To address #1129, this PR modifies some configurations for Semgrep in
pypi_sourcecode_analyzer
to allow unit tests to run completely offline.Description of changes
The following command line arguments are added to prevent operations in Semgrep that make network connections:
metrics.semgrep.dev:443
.After adding this, there are still network connections made by
semgrep scan --validate
to pull in linting rules. Currently, there is no way to run this without pulling in the rules using that remote connection (a feature request for this is here). To allow this functionality to still exist, instead of raising aConfigurationError
at initialisation, instead it logs a warning if the validation process failed, so if it failed due to being unable to make a network connection, it can still continue. The error is then cause in theanalyze
function when trying to run Semgrep. Changing this to a warning and not an error will not have an effect on any existing functionality.Related issues
Closes #1129.
Checklist
verified
label should appear next to all of your commits on GitHub.