Dark Mode

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix a false positive condition yaml_load#927

Merged
ericwb merged 1 commit intoPyCQA:mainfrom
ericwb:yaml_false_pos
Jul 10, 2022
Merged

Fix a false positive condition yaml_load#927
ericwb merged 1 commit intoPyCQA:mainfrom
ericwb:yaml_false_pos

Conversation

Copy link
Member

ericwb commented Jul 9, 2022

The yaml.load() function has a second argument that is typically
passed as a kwarg. However, someone could pass as a positional
argument as well. In such a case, Bandit would flag code passing
a SafeLoader even though that is validly secure.

The fix involves looking at the positional args. However, the
convenience function to do so also had no handling of ast.Attribute
as args. So get_call_arg_at_position() was modified to function much
like call_args().

Closes #546

Signed-off-by: Eric Brown eric_wade_brown@yahoo.com

The yaml.load() function has a second argument that is typically
passed as a kwarg. However, someone could pass as a positional
argument as well. In such a case, Bandit would flag code passing
a SafeLoader even though that is validly secure.

The fix involves looking at the positional args. However, the
convenience function to do so also had no handling of ast.Attribute
as args. So get_call_arg_at_position() was modified to function much
like call_args().

Closes PyCQA#546

Signed-off-by: Eric Brown
ericwb requested review from lukehinds and sigmavirus24 as code owners July 9, 2022 23:58
sigmavirus24 approved these changes Jul 10, 2022
ericwb merged commit 1067978 into PyCQA:main Jul 10, 2022
ericwb deleted the yaml_false_pos branch July 10, 2022 02:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

sigmavirus24 sigmavirus24 approved these changes

lukehinds Awaiting requested review from lukehinds lukehinds is a code owner

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

False-positive when Loader= not used in yaml.load(foo, yaml.SafeLoader)

2 participants