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

Show source and sink in output message #40

Merged
merged 1 commit into from
Mar 23, 2024
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
17 changes: 10 additions & 7 deletions lib/Zarn/AST.pm
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,23 @@
sub { $_[1] -> isa("PPI::Token::Symbol") and $_[1] -> content eq "\$$1" }
);

if ($var_token && $var_token -> can("parent")) {

Check failure on line 43 in lib/Zarn/AST.pm

View workflow job for this annotation

GitHub Actions / critic

Code structure is deeply nested at line 43, column 29. Consider refactoring.
if ((

Check failure on line 44 in lib/Zarn/AST.pm

View workflow job for this annotation

GitHub Actions / critic

Code structure is deeply nested at line 44, column 33. Consider refactoring.
$var_token -> parent -> isa("PPI::Token::Operator") ||
$var_token -> parent -> isa("PPI::Statement::Expression")
)) {
my ($line, $rowchar) = @{$token -> location};
my ($line_sink, $rowchar_sink) = @{$token -> location};
my ($line_source, $rowchar_source) = @{$var_token -> location};

push @results, {
category => $category,
file => $file,
title => $title,
message => $message,
line => $line,
rowchar => $rowchar
category => $category,
file => $file,
title => $title,
message => $message,
line_sink => $line_sink,
rowchar_sink => $rowchar_sink,
line_source => $line_source,
rowchar_source => $rowchar_source
};
}
}
Expand Down
14 changes: 8 additions & 6 deletions zarn.pl
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,15 @@ sub main {
}

foreach my $result (@results) {
my $category = $result -> {category};
my $file = $result -> {file};
my $title = $result -> {title};
my $line = $result -> {line};
my $rowchar = $result -> {rowchar};
my $category = $result -> {category};
my $file = $result -> {file};
my $title = $result -> {title};
my $line_sink = $result -> {line_sink};
my $rowchar_sink = $result -> {rowchar_sink};
my $line_source = $result -> {line_source};
my $rowchar_source = $result -> {rowchar_source};

print "[$category] - FILE:$file \t Potential: $title. \t Line: $line:$rowchar\n";
print "[$category] - FILE:$file \t Potential: $title. \t Dangerous function on line: $line_sink:$rowchar_sink \t Data point possibility controlled: $line_source:$rowchar_source\n";
}

if ($sarif) {
Expand Down
Loading