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

Improve Makefiles for generating scanner documentation #950

Merged
merged 24 commits into from
Feb 3, 2022

Conversation

Weltraumschaf
Copy link
Member

No description provided.

It is easier to maintain the location of directories at one
place.

Also use built in functions to find files w/ glob patterns
instead of convoluted shell script magic.

Signed-off-by: Sven Strittmatter <sven.strittmatter@iteratec.com>
Since macOS and maybe BSD does not support .ONESHELL for
make targets we must removethis. To make the shell commands
work ;\ must be appended to each line, except block open
keywords such as 'then' or 'else'.

This path also utilizes the SCANNERS_CHART_LIST variable
instead of the find.

Signed-off-by: Sven Strittmatter <sven.strittmatter@iteratec.com>
Signed-off-by: Sven Strittmatter <sven.strittmatter@iteratec.com>
Jumping around with relative dirs is very brittle. Better pattern
is to define a variable with absolute location and references this.

Signed-off-by: Sven Strittmatter <sven.strittmatter@iteratec.com>
Also use absolute path to be more stable for refactorings.

Signed-off-by: Sven Strittmatter <sven.strittmatter@iteratec.com>
Signed-off-by: Sven Strittmatter <sven.strittmatter@iteratec.com>
Signed-off-by: Sven Strittmatter <sven.strittmatter@iteratec.com>
Forunknown reason helm-docs need to be in the scanner dir. Maybe
it assumes some files relative to the Chart.yaml

Until I discovered this issue using the cd as workaround.

Signed-off-by: Sven Strittmatter <sven.strittmatter@iteratec.com>
Because it is shell script anyway and editing shell script in
Makefiles is tedious I decided to extract the code into a separate
shell script. So we can invoke this from the make targets.

AFAICS there is lots of duplicatedcode for hooks and parser. Seems
to be nearly the same as for the scanners. So we may reuse thisscript.

This will elad into a cleaner Makefile and less code to maintain.

Signed-off-by: Sven Strittmatter <sven.strittmatter@iteratec.com>
@Weltraumschaf Weltraumschaf added the enhancement New feature or request label Feb 1, 2022
@Weltraumschaf Weltraumschaf self-assigned this Feb 1, 2022
@Weltraumschaf Weltraumschaf added this to Backlog in secureCodeBox v3 via automation Feb 1, 2022
@Weltraumschaf Weltraumschaf marked this pull request as draft February 1, 2022 20:42
@Weltraumschaf Weltraumschaf moved this from Backlog to In progress in secureCodeBox v3 Feb 1, 2022
@Weltraumschaf Weltraumschaf linked an issue Feb 1, 2022 that may be closed by this pull request
@Weltraumschaf Weltraumschaf marked this pull request as ready for review February 1, 2022 20:46
@Weltraumschaf Weltraumschaf moved this from In progress to To Review in secureCodeBox v3 Feb 1, 2022
@malexmave
Copy link
Member

malexmave commented Feb 2, 2022

Does not seem to work for me...

Test process:

  • Check out branch
  • Make change to scanners/gitleaks/.helm-docs.gotmpl
  • In root directory of repo, run make scanner-docs
  • Process terminates without showing an error code, but READMEs are not updated to reflect the change in the template.

Relevant log snippet:

Parser found at: /Users/mmaass/Documents/Code/SecureCodeBox/scanners/gitleaks/parser
INFO[2022-02-02T08:14:04+01:00] Found Chart directories [.]                  
INFO[2022-02-02T08:14:04+01:00] Generating README Documentation for chart /Users/mmaass/Documents/Code/SecureCodeBox/scanners/gitleaks 
WARN[2022-02-02T08:14:04+01:00] Could not open chart README file /Users/mmaass/Documents/Code/SecureCodeBox/scanners/gitleaks/README.md, skipping chart 
Scanner found at: /Users/mmaass/Documents/Code/SecureCodeBox/scanners/gitleaks/scanner
INFO[2022-02-02T08:14:04+01:00] Found Chart directories [.]                  
INFO[2022-02-02T08:14:04+01:00] Generating README Documentation for chart /Users/mmaass/Documents/Code/SecureCodeBox/scanners/gitleaks 
WARN[2022-02-02T08:14:04+01:00] Could not open chart README file /Users/mmaass/Documents/Code/SecureCodeBox/scanners/gitleaks/README.md, skipping chart 
INFO[2022-02-02T08:14:04+01:00] Found Chart directories [.]                  
INFO[2022-02-02T08:14:04+01:00] Generating README Documentation for chart /Users/mmaass/Documents/Code/SecureCodeBox/scanners/gitleaks 
WARN[2022-02-02T08:14:04+01:00] Could not open chart README file /Users/mmaass/Documents/Code/SecureCodeBox/scanners/gitleaks/README.md, skipping chart 

Let me know if I can help debug this in any way.

@Weltraumschaf
Copy link
Member Author

ACK. I thought this was a general warning, but I cross checked on a Debian machine: No such warnings. I have no clue why it occurs because the printed filename is accessible and I have no idea why helm-docs can't open it.

@malexmave
Copy link
Member

Maybe @J12934 has an idea what is going on there?

@Weltraumschaf
Copy link
Member Author

@J12934 Also something I don't understand: Why is it necessary forheln-docs to be executed inside the scanner directory, when I reference all given template files?

@Weltraumschaf Weltraumschaf force-pushed the bugfix/issue_754 branch 2 times, most recently from 110854c to 4531c4d Compare February 2, 2022 11:04
@Weltraumschaf
Copy link
Member Author

Loglevel trace ofhelm-docs is not helpfull.

@Weltraumschaf
Copy link
Member Author

@malexmave Fixed! Would you please test on your machine?

@malexmave
Copy link
Member

malexmave commented Feb 2, 2022

Works on my machine now 🥳 . However, only for scanner-docs, not for hook-docs.

Signed-off-by: Sven Strittmatter <sven.strittmatter@iteratec.com>
Signed-off-by: Sven Strittmatter <sven.strittmatter@iteratec.com>
Signed-off-by: Sven Strittmatter <sven.strittmatter@iteratec.com>
Signed-off-by: Sven Strittmatter <sven.strittmatter@iteratec.com>
Signed-off-by: Sven Strittmatter <sven.strittmatter@iteratec.com>
…values

Signed-off-by: Sven Strittmatter <sven.strittmatter@iteratec.com>
Signed-off-by: Sven Strittmatter <sven.strittmatter@iteratec.com>
Signed-off-by: Sven Strittmatter <sven.strittmatter@iteratec.com>
We log this anyway in the called shell script anddoes not need
the info twice.

Signed-off-by: Sven Strittmatter <sven.strittmatter@iteratec.com>
Signed-off-by: Sven Strittmatter <sven.strittmatter@iteratec.com>
So we do not need to cd around.

Signed-off-by: Sven Strittmatter <sven.strittmatter@iteratec.com>
helm-docs expets only a filename which is relative to the found
Chart.yaml. So we simply add the 'docs' part.

Signed-off-by: Sven Strittmatter <sven.strittmatter@iteratec.com>
Signed-off-by: Sven Strittmatter <sven.strittmatter@iteratec.com>
@Weltraumschaf Weltraumschaf force-pushed the bugfix/issue_754 branch 2 times, most recently from f569c41 to f255186 Compare February 2, 2022 13:29
Signed-off-by: Sven Strittmatter <sven.strittmatter@iteratec.com>
Signed-off-by: GitHub Actions <securecodebox@iteratec.com>
secureCodeBox v3 automation moved this from To Review to Reviewer approved Feb 2, 2022
Copy link
Member

@malexmave malexmave left a comment

Choose a reason for hiding this comment

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

Works for me, and results are now also consistent with those obtained by the CI job.

@Weltraumschaf
Copy link
Member Author

Can you merge? You should have the rights.

@malexmave malexmave changed the title Bugfix/issue 754 Improve Makefiles for generating scanner documentation Feb 3, 2022
@malexmave malexmave merged commit 644adba into main Feb 3, 2022
secureCodeBox v3 automation moved this from Reviewer approved to Done Feb 3, 2022
@malexmave malexmave deleted the bugfix/issue_754 branch February 3, 2022 08:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

make scanner-docs / hook-docs fails on macOS
2 participants