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

consume csgrep changes to support a new option: limit-msg-len (OSH-67) #114

Conversation

lbossis
Copy link
Contributor

@lbossis lbossis commented Jul 27, 2023

First cut

@kdudka
Copy link
Member

kdudka commented Jul 27, 2023

@lbossis Thanks! I have not tried it myself but the code change looks good. Some minor remarks:

  • The option needs to start with the gitleaks prefix because it is specific the the gitleaks plug-in: --gitleaks-limit-msg-len
  • I would use a higher default value (say 512) for the new option.
  • The commit summary should describe the changes from csmock perspective, something like:
gitleaks: implement --gitleaks-limit-msg-len defaulting to 512

Implementation details can go to commit description in needed.

  • We need to make csmock-plugin-gitleaks depend on the updated version of csdiff:
--- a/make-srpm.sh
+++ b/make-srpm.sh
@@ -175,6 +175,7 @@ This package contains the divine plug-in for csmock.
 %package -n csmock-plugin-gitleaks
 Summary: experimental csmock plug-in
 Requires: csmock-common
+Requires: csdiff > 3.0.3

 %description -n csmock-plugin-gitleaks
 This package contains the gitleaks plug-in for csmock.

Without the dependency, the scans would fail on the missing csgrep option if someone forgot to update the csdiff package.

py/plugins/gitleaks.py Outdated Show resolved Hide resolved
@lbossis
Copy link
Contributor Author

lbossis commented Aug 3, 2023

Removed prefix gitleaks- from FILTER_CMD which calls csgrep. Looks like it works! I executed the following command
csmock -t cppcheck,clang,gitleaks --gitleaks-limit-msg-len=24 nss-util-3.90.0-1.el7_9.src.rpm
the tail of output is found at http://pastebin.test.redhat.com/1106663
Please, do your testing and let's merge this branch limit-amount-of-results-produced-by-single-scan--OSH-67 to main.

@lbossis lbossis marked this pull request as ready for review August 4, 2023 13:14
Copy link
Member

@kdudka kdudka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lbossis Thanks for the update! Now you need to squash all the fix-up commits and rewrite the commit message as described in #114 (comment). This way we end up with a clean git history where each snapshot can be built and tested. This is crucial for using git bisect later on.

@@ -124,7 +124,7 @@ Tool for plugging static analyzers into the build process, free of mock.

%package -n csmock-common
Summary: Core of csmock (a mock wrapper for Static Analysis tools)
Requires: csdiff > 3.0.2
Requires: csdiff > 3.0.3
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is in fact a dependency of csmock-plugin-gitleaks but bumping the csmock-common requirement should be harmless, too.

@lbossis lbossis force-pushed the limit-amount-of-results-produced-by-single-scan--OSH-67 branch from 25693d6 to 0579922 Compare August 15, 2023 16:50
@lbossis
Copy link
Contributor Author

lbossis commented Aug 15, 2023 via email

@lzaoral
Copy link
Member

lzaoral commented Aug 16, 2023

Thanks for the question, @lbossis! Yes, we need two empty lines to stay conformant to the official Python Style Guide (PEP8). The section about blank lines explicitly says:

Blank Lines
Surround top-level function and class definitions with two blank lines.
...

which is exactly our case!

edit: typos

@lbossis lbossis force-pushed the limit-amount-of-results-produced-by-single-scan--OSH-67 branch from 45aea4b to d099df6 Compare August 16, 2023 14:42
@kdudka
Copy link
Member

kdudka commented Aug 16, 2023

@lbossis Thanks for the update! Could you please update the commit message summary as requested at #114 (comment) ?

The gitleaks: prefix is crucial here because the changes are specific to a single plug-in of csmock.

@lbossis lbossis force-pushed the limit-amount-of-results-produced-by-single-scan--OSH-67 branch from d099df6 to 94e2152 Compare August 17, 2023 01:25
@kdudka
Copy link
Member

kdudka commented Aug 17, 2023

@lbossis Thanks for the update! Unfortunately the commit message needs to be reformatted like this:

gitleaks: implement --gitleaks-limit-msg-len defaulting to 512

This package contains an extension of gitleaks plug-in to support a new
command line option for controlling event message length from csmock.
csmock-plugin-gitleaks is dependent on the updated version of csdiff

Fixes: https://github.com/csutils/csdiff/issues/114
Related: https://issues.redhat.com/browse/OSH-67

The git commit summary is the first line of the commit message, delimited by a blank line from the description. The commit message summary has a special semantics in git. See the git-commit(1) man page:

Though not required, it’s a good idea to begin the commit message with a single short (less than 50 character) line summarizing the change, followed by a blank line and then a more thorough description. The text up to the first blank line in a commit message is treated as the commit title, and that title is used throughout Git. For example, git-format-patch(1) turns a commit into email, and it uses the title on the Subject line and the rest of the commit in the body.

You can easily update the commit message with: git commit --amend && git push --force

@lbossis lbossis force-pushed the limit-amount-of-results-produced-by-single-scan--OSH-67 branch from 94e2152 to e20c8d0 Compare August 17, 2023 13:09
@lbossis
Copy link
Contributor Author

lbossis commented Aug 17, 2023 via email

This package contains an extension of gitleaks plug-in to support a new
command line option for controlling event message length from csmock.
csmock-plugin-gitleaks is dependent on the updated version of csdiff

Closes: csutils#114
Related: https://issues.redhat.com/browse/OSH-67
@kdudka kdudka force-pushed the limit-amount-of-results-produced-by-single-scan--OSH-67 branch from e20c8d0 to ac7541f Compare August 17, 2023 15:07
@kdudka
Copy link
Member

kdudka commented Aug 17, 2023

The original commit message referenced an unrelated csdiff issue by mistake (csutils/csdiff#114) so I have fixed it to make it reference this pull request instead. Merging...

@kdudka kdudka closed this in ac7541f Aug 17, 2023
@kdudka kdudka merged commit ac7541f into csutils:main Aug 17, 2023
3 of 29 checks passed
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.

3 participants