-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
59 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import paramiko | ||
|
||
paramiko.exec_command('something; really; unsafe') |
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
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
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
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
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
34 changes: 34 additions & 0 deletions
34
crates/ruff/src/rules/flake8_bandit/rules/paramiko_calls.rs
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,34 @@ | ||
use rustpython_parser::ast::{Expr, Ranged}; | ||
|
||
use ruff_diagnostics::{Diagnostic, Violation}; | ||
use ruff_macros::{derive_message_formats, violation}; | ||
|
||
use crate::checkers::ast::Checker; | ||
|
||
#[violation] | ||
pub struct ParamikoCalls; | ||
|
||
impl Violation for ParamikoCalls { | ||
#[derive_message_formats] | ||
fn message(&self) -> String { | ||
format!("Possible shell injection via Paramiko call, check inputs are properly sanitized") | ||
} | ||
} | ||
|
||
/// S601 | ||
pub(crate) fn paramiko_calls( | ||
checker: &mut Checker, | ||
func: &Expr, | ||
) { | ||
if checker | ||
.ctx | ||
.resolve_call_path(func) | ||
.map_or(false, |call_path| { | ||
call_path.as_slice() == ["paramiko", "exec_command"] | ||
}) | ||
{ | ||
checker | ||
.diagnostics | ||
.push(Diagnostic::new(ParamikoCalls, func.range())); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...ff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S601_S601.py.snap
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,12 @@ | ||
--- | ||
source: crates/ruff/src/rules/flake8_bandit/mod.rs | ||
--- | ||
S601.py:3:1: S601 Possible shell injection via Paramiko call, check inputs are properly sanitized | ||
| | ||
3 | import paramiko | ||
4 | | ||
5 | paramiko.exec_command('something; really; unsafe') | ||
| ^^^^^^^^^^^^^^^^^^^^^ S601 | ||
| | ||
|
||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.