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

Change: limit copyright year check to fileheader and copyright tag #743

Merged
merged 1 commit into from
Aug 28, 2024

Conversation

NiklasHargarter
Copy link
Contributor

What

Rework check_copyright_year to only check lines in the NASL fileheader and the script_copyright tag.

The NASL header starts at the beginning of the file. Each line of it must start with a '#'. The first line that does not contain a '#' is no longer part of the header. Only a single continuous header is tested.
script_copyright tag value is retrieved directly with helper pattern.

Changed regex for identifying copyright and its year.
Special cases where an additional copyright that does not cover since creation, but starts later, does not need to be added to the ignore list, as long as it follows the same format as the one in gather-package-list.nasl. Then it will not pass the regex and will not throw a lintererror if there is a newer year. But you have to check manually if these are correct.

Example:
        if creation year = 2008
    ok:
    # SPDX-FileCopyrightText: 2008 Tim Brown
    
    not ok / needs ignore entry:
    # SPDX-FileCopyrightText: 2009 Greenbone AG
    # New NASL / detection code since 2018 Copyright (C) 2018 Greenbone AG

    ignored:
    # SPDX-FileCopyrightText: New detection methods / pattern / code since 2009 Greenbone AG \\Example from gather-package-list.nasl

Ignore-list is reset.
https://github.com/greenbone/vulnerability-tests/pull/12683 fixes the necessary files that would now trigger a error.
With this PR, this check now finds 0 errors in the VT repo.

Why

It would erroneously identify copyrights in files that were not actually copyrights of that file but just part of comments.

References

VTOPS-230

Checklist

  • Tests (Rewritten, additional cases where added)

@NiklasHargarter NiklasHargarter requested a review from a team as a code owner August 28, 2024 10:32
Copy link

Conventional Commits Report

Type Number
Changed 1

🚀 Conventional commits found.

Copy link

codecov bot commented Aug 28, 2024

Codecov Report

Attention: Patch coverage is 97.43590% with 1 line in your changes missing coverage. Please review.

Project coverage is 79.66%. Comparing base (5ea203f) to head (5726785).
Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
troubadix/plugins/copyright_year.py 97.43% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #743      +/-   ##
==========================================
+ Coverage   79.51%   79.66%   +0.14%     
==========================================
  Files          86       86              
  Lines        2910     2926      +16     
  Branches      626      630       +4     
==========================================
+ Hits         2314     2331      +17     
  Misses        450      450              
+ Partials      146      145       -1     

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

@mbrinkhoff mbrinkhoff force-pushed the rework_check_copyright_year branch from 5c32e26 to 5726785 Compare August 28, 2024 23:02
@mbrinkhoff mbrinkhoff enabled auto-merge (rebase) August 28, 2024 23:02
@mbrinkhoff mbrinkhoff added the make release To trigger GitHub release action label Aug 28, 2024
@mbrinkhoff mbrinkhoff merged commit ac32714 into main Aug 28, 2024
10 checks passed
@mbrinkhoff mbrinkhoff deleted the rework_check_copyright_year branch August 28, 2024 23:03
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.

2 participants