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

Documentation on adding new rules and analyzers #1262

Merged
merged 11 commits into from
Dec 16, 2024

Conversation

dannyc-grafana
Copy link
Contributor

@dannyc-grafana dannyc-grafana commented Dec 11, 2024

Add some docs for developers who want to extend gosec-- this is based on my personal notes I took while attempting to add a taint analyzer (it didn't pan out, but I intend to keep looking into it).

I've also drawn a diagram in miro, which I will add in a future PR once I figure out how to export it to useful file format.

Add some docs for developers who want to extend gosec
@codecov-commenter
Copy link

codecov-commenter commented Dec 12, 2024

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 66.66%. Comparing base (1216c9b) to head (1f418c4).
Report is 22 commits behind head on master.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1262      +/-   ##
==========================================
- Coverage   68.49%   66.66%   -1.84%     
==========================================
  Files          75       75              
  Lines        4384     5186     +802     
==========================================
+ Hits         3003     3457     +454     
- Misses       1233     1581     +348     
  Partials      148      148              

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

Copy link
Member

@ccojocar ccojocar left a comment

Choose a reason for hiding this comment

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

Thanks for putting this together. I left a few comments, it would be great if you could address them.

CONTRIBUTING.md Outdated Show resolved Hide resolved
CONTRIBUTING.md Outdated Show resolved Hide resolved
CONTRIBUTING.md Outdated Show resolved Hide resolved
CONTRIBUTING.md Show resolved Hide resolved
@ccojocar
Copy link
Member

I would also add a link in the README to this doc. Maybe in the development section https://github.com/securego/gosec?tab=readme-ov-file#development.

CONTRIBUTING.md Outdated Show resolved Hide resolved
Co-authored-by: Oleksandr Redko <[email protected]>
CONTRIBUTING.md Outdated Show resolved Hide resolved
CONTRIBUTING.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
dannyc-grafana and others added 3 commits December 13, 2024 13:28
Co-authored-by: Oleksandr Redko <[email protected]>
Co-authored-by: Oleksandr Redko <[email protected]>
Co-authored-by: Oleksandr Redko <[email protected]>
CONTRIBUTING.md Outdated Show resolved Hide resolved
CONTRIBUTING.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
Fix phrasing to be clearer

### Adding an Analyzer

1. Create a new go file under `./analyzers/` with the following scaffolding in it:
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpicking

Suggested change
1. Create a new go file under `./analyzers/` with the following scaffolding in it:
1. Create a new Go file under `./analyzers/` with the following scaffolding in it:
Suggested change
1. Create a new go file under `./analyzers/` with the following scaffolding in it:
1. Create a new .go file under `./analyzers/` with the following scaffolding in it:


2. Add the analyzer to `./analyzers/analyzerslist.go` in the `defaultAnalyzers` variable under an entry like `{"G999", "My test analyzer", newMyAnalyzer}`
3. Add a RuleID to CWE ID mapping for your rule to the `ruleToCWE` map in `./issue/issue.go`. If you need a CWE that isn't already defined in `./cwe/data.go`, add it to the `idWeaknessess` map in that file.
4. `make`; then run the `gosec` binary produced. You should see the output from our print statement.
Copy link
Contributor

Choose a reason for hiding this comment

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

It's about the make command

Suggested change
4. `make`; then run the `gosec` binary produced. You should see the output from our print statement.
4. Run `make`; then run the `gosec` binary produced. You should see the output from our print statement.

Or anything like that

@ccojocar ccojocar merged commit 09b9143 into securego:master Dec 16, 2024
6 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.

5 participants