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

Add: Add a standalone plugin for checking correct file extensions #687

Merged
merged 11 commits into from
Apr 8, 2024

Conversation

ghost
Copy link

@ghost ghost commented Mar 27, 2024

What

Add a standalone plugin that checks that all files in a given directory and subdirectories have only valid .nasl or .inc file extensions.

Why

Files with invalid extensions make it into the feed.
Invalid: foo.nasl.nasl, foo, codespell.exclusion
Valid: foo.nasl, foo.inc

References

VTOPS-198

Checklist

  • Tests
nhargarter@gb-ho-10 ~/g/troubadix (file_extensions)> poetry run troubadix-file-extensions -d ~/gb/vulnerability-tests/nasl
Files with unwanted file extension were found:
/home/nhargarter/gb/vulnerability-tests/nasl/README.md
/home/nhargarter/gb/vulnerability-tests/nasl/21.04/.git-keep
/home/nhargarter/gb/vulnerability-tests/nasl/common/bad_rsa_ssh_host_keys.txt
/home/nhargarter/gb/vulnerability-tests/nasl/common/bad_dsa_ssh_host_keys.txt
/home/nhargarter/gb/vulnerability-tests/nasl/common/2023/wordpress-plugins/gb_wordpress_woocommerce-gutenberg-products-block_xss_vuln_nov23.nasl.nasl
/home/nhargarter/gb/vulnerability-tests/nasl/common/2023/wordpress-plugins/gb_wordpress_better_font_awesome_xss_vuln_jan23.nasl.nasl
/home/nhargarter/gb/vulnerability-tests/nasl/common/2022/discourse/gb_discourse_rce_vuln_sep22.nasl.nasl
/home/nhargarter/gb/vulnerability-tests/nasl/22.04/.git-keep

Copy link

github-actions bot commented Mar 27, 2024

Conventional Commits Report

Type Number
Changed 5
Added 4

🚀 Conventional commits found.

Copy link

codecov bot commented Mar 27, 2024

Codecov Report

Attention: Patch coverage is 94.00000% with 3 lines in your changes are missing coverage. Please review.

Project coverage is 79.06%. Comparing base (d9d6eb9) to head (ffc9b71).

❗ Current head ffc9b71 differs from pull request most recent head 792a7e8. Consider uploading reports for the commit 792a7e8 to get more accurate results

Files Patch % Lines
troubadix/standalone_plugins/file_extensions.py 95.91% 1 Missing and 1 partial ⚠️
troubadix/standalone_plugins/changed_oid.py 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #687      +/-   ##
==========================================
+ Coverage   78.76%   79.06%   +0.30%     
==========================================
  Files          81       82       +1     
  Lines        2736     2785      +49     
  Branches      577      589      +12     
==========================================
+ Hits         2155     2202      +47     
- Misses        440      441       +1     
- Partials      141      142       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ghost ghost marked this pull request as ready for review March 28, 2024 09:57
@ghost ghost self-requested a review as a code owner March 28, 2024 09:57
@ghost ghost force-pushed the file_extensions branch from 5b00d48 to 81f8c02 Compare March 28, 2024 09:58
@cfi-gb
Copy link
Member

cfi-gb commented Mar 28, 2024

For these we would need to have an exclusion possibility (no exclusion of .txt or .md files in general, only for these specific file names) as these are valid and shouldn't be reported:

nasl/README.md
nasl/21.04/.git-keep
nasl/common/bad_rsa_ssh_host_keys.txt
nasl/common/bad_dsa_ssh_host_keys.txt
nasl/22.04/.git-keep

The .git-keep is TBD, as both folders (21.04 and 22.04) are not empty we might also want to just drop it but not sure if this could cause problems during feed deployment / QA.

@ghost
Copy link
Author

ghost commented Mar 28, 2024

For these we would need to have an exclusion possibility (no exclusion of .txt or .md files in general, only for these specific file names) as these are valid and shouldn't be reported:

nasl/README.md
nasl/21.04/.git-keep
nasl/common/bad_rsa_ssh_host_keys.txt
nasl/common/bad_dsa_ssh_host_keys.txt
nasl/22.04/.git-keep

The .git-keep is TBD, as both folders (21.04 and 22.04) are not empty we might also want to just drop it but not sure if this could cause problems during feed deployment / QA.

Should the exclusion be for the specific file in the specific folder starting with /nasl/, or should it be a general exclusion for files with that specific name?

exclusion: common/bad_dsa_ssh_host_keys.txt vs bad_dsa_ssh_host_keys.txt

@cfi-gb
Copy link
Member

cfi-gb commented Mar 28, 2024

For these we would need to have an exclusion possibility (no exclusion of .txt or .md files in general, only for these specific file names) as these are valid and shouldn't be reported:

nasl/README.md
nasl/21.04/.git-keep
nasl/common/bad_rsa_ssh_host_keys.txt
nasl/common/bad_dsa_ssh_host_keys.txt
nasl/22.04/.git-keep

The .git-keep is TBD, as both folders (21.04 and 22.04) are not empty we might also want to just drop it but not sure if this could cause problems during feed deployment / QA.

Should the exclusion be for the specific file in the specific folder starting with /nasl/, or should it be a general exclusion for files with that specific name?

exclusion: common/bad_dsa_ssh_host_keys.txt vs bad_dsa_ssh_host_keys.txt

Personally i would make it as strict as possible (e.g. some one might have copied the file wrongly to e.g. common/2024):

common/bad_dsa_ssh_host_keys.txt

with an option to also allow something like e.g. the following (if that is ever required to overwrite the file in different feeds) in the future:

21.04/bad_dsa_ssh_host_keys.txt
22.04/bad_dsa_ssh_host_keys.txt

@mbrinkhoff
Copy link
Member

[tool.poetry.scripts]

There is also an requirement to add this to the pyproject.toml file, so it can be run as a cmd tool

@cfi-gb cfi-gb added the make release To trigger GitHub release action label Apr 3, 2024
@ghost ghost force-pushed the file_extensions branch from ffc9b71 to 0c1f82f Compare April 8, 2024 09:49
@mbrinkhoff mbrinkhoff enabled auto-merge (rebase) April 8, 2024 09:52
@mbrinkhoff mbrinkhoff merged commit 89a1d57 into main Apr 8, 2024
10 checks passed
@mbrinkhoff mbrinkhoff deleted the file_extensions branch April 8, 2024 09:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
make release To trigger GitHub release action
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants