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

feat: add bandit as defined-formats #129

Merged
merged 2 commits into from
Sep 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions fmts/doc.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions fmts/python.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,15 @@ func init() {
URL: "https://github.com/PyCQA/pydocstyle",
Language: lang,
})
register(&Fmt{
Name: "bandit",
Errorformat: []string{
`%f:%l: B%n[bandit]: %tIGH: %m`,
`%f:%l: B%n[bandit]: %tEDIUM: %m`,
`%f:%l: B%n[bandit]: %tOW: %m`,
},
Description: "A tool designed to find common security issues in Python code.",
URL: "https://github.com/PyCQA/bandit.git",
Language: lang,
})
}
4 changes: 4 additions & 0 deletions fmts/testdata/bandit.in
Copy link
Contributor

Choose a reason for hiding this comment

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

This output is in a human-readable format.
It is better to use the custom formatter and pass it to errorformat.

Copy link
Member

Choose a reason for hiding this comment

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

While I definitely agree that it's better to use custom formatter and output rdjson or use json formatter, I'm fine with including this change for handy use for now.

WDYT?

Copy link
Member Author

Choose a reason for hiding this comment

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

I changed format human-readable to the custom formatter in 72b569d

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks!

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/workspaces/errorformat/test.py:1: B404[bandit]: LOW: Consider possible security implications associated with the subprocess module.
/workspaces/errorformat/test.py:5: B105[bandit]: LOW: Possible hardcoded password: 'aaa'
/workspaces/errorformat/test.py:8: B307[bandit]: MEDIUM: Use of possibly insecure function - consider using safer ast.literal_eval.
/workspaces/errorformat/test.py:11: B304[bandit]: HIGH: Use of insecure cipher Crypto.Cipher.XOR.new. Replace with a known secure cipher such as AES.
4 changes: 4 additions & 0 deletions fmts/testdata/bandit.ok
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/workspaces/errorformat/test.py|1 L 404| Consider possible security implications associated with the subprocess module.
/workspaces/errorformat/test.py|5 L 105| Possible hardcoded password: 'aaa'
/workspaces/errorformat/test.py|8 M 307| Use of possibly insecure function - consider using safer ast.literal_eval.
/workspaces/errorformat/test.py|11 H 304| Use of insecure cipher Crypto.Cipher.XOR.new. Replace with a known secure cipher such as AES.
Loading