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

fix(security): Improve SQL in version_signature.py #1248

Merged
merged 4 commits into from
Jul 15, 2021

Conversation

terriko
Copy link
Contributor

@terriko terriko commented Jul 14, 2021

You can't use bound parameters for things like table names that aren't technically parameters in sqlite3, but Bandit throws errors due to the string construction in queries. Added some basic input validation into the init function and marked lines for Bandit. Because bandit doesn't deal well with multi-lines with nosec comments, I've added descriptive comments to some select statements instead of the # nosec line that would make the line disappear from future runs of Bandit.

Signed-off-by: Terri Oda terri.oda@intel.com

* improves version_signature.py to align with bandit's guidance
* fixes intel#1229

Signed-off-by: Terri Oda <terri.oda@intel.com>
You can't use bound parameters for things like table names that aren't
technically parameters in sqlite3.  Moved some basic input validation
into the init function and marked lines for bandit.  Because bandit
doesn't deal well with multi-lines with `nosec` comments, I've added
descriptive comments to some select statements.

Signed-off-by: Terri Oda <terri.oda@intel.com>
@codecov-commenter
Copy link

Codecov Report

Merging #1248 (2e7e076) into main (ed93b01) will decrease coverage by 1.69%.
The diff coverage is 42.85%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1248      +/-   ##
==========================================
- Coverage   78.29%   76.60%   -1.70%     
==========================================
  Files         243      243              
  Lines        4496     4500       +4     
  Branches      557      558       +1     
==========================================
- Hits         3520     3447      -73     
- Misses        840      907      +67     
- Partials      136      146      +10     
Flag Coverage Δ
longtests 76.60% <42.85%> (-1.70%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
cve_bin_tool/version_signature.py 74.50% <42.85%> (-2.09%) ⬇️
cve_bin_tool/checkers/xml2.py 61.36% <0.00%> (-27.28%) ⬇️
test/test_json.py 68.96% <0.00%> (-20.69%) ⬇️
test/test_scanner.py 61.71% <0.00%> (-12.50%) ⬇️
test/test_cli.py 81.28% <0.00%> (-11.83%) ⬇️
cve_bin_tool/checkers/systemd.py 85.18% <0.00%> (-7.41%) ⬇️
cve_bin_tool/checkers/glibc.py 96.29% <0.00%> (-3.71%) ⬇️
cve_bin_tool/cli.py 75.15% <0.00%> (-3.04%) ⬇️
cve_bin_tool/cvedb.py 84.39% <0.00%> (-2.23%) ⬇️
cve_bin_tool/version_scanner.py 75.86% <0.00%> (-1.38%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ed93b01...2e7e076. Read the comment docs.

@terriko terriko requested a review from pdxjohnny July 14, 2021 20:28
Co-authored-by: John Andersen <johnandersenpdx@gmail.com>
@terriko terriko merged commit 38c42be into intel:main Jul 15, 2021
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

Successfully merging this pull request may close these issues.

Improve SQL queries in version_signature.py to align with Bandit guidance
3 participants