-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check for no action passed in argparse rule (#396)
The default value for action when no value is passed is "store" which is the exact value we are trying to detect for issues. So if a program creates CLI arguments via add_argument with api-key or password arg and unset action, it needs to surface this as an issue. Signed-off-by: Eric Brown <eric.brown@securesauce.dev>
- Loading branch information
Showing
3 changed files
with
19 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
tests/unit/rules/python/stdlib/argparse/examples/argparse_add_argument_default_action.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# level: ERROR | ||
# start_line: 13 | ||
# end_line: 17 | ||
# start_column: 0 | ||
# end_column: 1 | ||
import argparse | ||
|
||
|
||
parser = argparse.ArgumentParser( | ||
prog="ProgramName", | ||
description="What the program does", | ||
) | ||
parser.add_argument( | ||
"--api-key", | ||
dest="api_key", | ||
help="API key to connect to the server", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters