Skip to content
This repository has been archived by the owner on Nov 28, 2023. It is now read-only.

Commit

Permalink
only show important info
Browse files Browse the repository at this point in the history
  • Loading branch information
FeeiCN committed Dec 18, 2017
1 parent 5a7de01 commit c098a7e
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
10 changes: 4 additions & 6 deletions cobra/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,7 @@ def score2level(score):
score_full = '0{s}'.format(s=score)
else:
score_full = score

a = '{s}{e}'.format(s=score * '■', e=(10 - score) * '□')
return '{l}-{s}: {ast}'.format(l=level[:1], s=score_full, ast=a)
return '{l}-{s}'.format(l=level[:1], s=score_full)


def scan_single(target_directory, single_rule):
Expand Down Expand Up @@ -202,12 +200,12 @@ def store(result):

# print
data = []
table = PrettyTable(['#', 'CVI', 'VUL', 'Rule', 'Lang', 'Level-Score', 'Target', 'Commit(Time, Author)', 'Source Code Content', 'Analysis'])
table = PrettyTable(['#', 'CVI', 'Rule', 'Level', 'Target', 'Source Code Content'])
table.align = 'l'
trigger_rules = []
for idx, x in enumerate(find_vulnerabilities):
trigger = '{fp}:{ln}'.format(fp=x.file_path, ln=x.line_number)
commit = u'{time}, @{author}'.format(author=x.commit_author, time=x.commit_time)
# commit = u'{time}, @{author}'.format(author=x.commit_author, time=x.commit_time)
level = score2level(x.level)
cvi = x.id[0:3]
if cvi in vulnerabilities:
Expand All @@ -218,7 +216,7 @@ def store(result):
code_content = x.code_content[:50].strip()
except AttributeError as e:
code_content = x.code_content.decode('utf-8')[:100].strip()
row = [idx + 1, x.id, cvn, x.rule_name, x.language, level, trigger, commit, code_content, x.analysis]
row = [idx + 1, x.id, x.rule_name, level, trigger, code_content]
data.append(row)
table.add_row(row)
if x.id not in trigger_rules:
Expand Down
2 changes: 1 addition & 1 deletion rules/CVI-160003.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<cobra document="https://github.com/wufeifei/cobra">
<name value="MySQL Execute Functions可能导致SQL注入"/>
<name value="MySQL Execute Functions"/>
<language value="php"/>
<match mode="function-param-controllable"><![CDATA[(mysql_query|mysql_db_query)]]></match>
<repair block="in-function"><![CDATA[(mysql_real_escape_string|addslashes)]]></repair>
Expand Down
2 changes: 1 addition & 1 deletion rules/CVI-160004.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<cobra document="https://github.com/wufeifei/cobra">
<name value="SQL Execute Functions可能导致SQL注入"/>
<name value="SQL Execute Functions"/>
<language value="php"/>
<match mode="function-param-controllable"><![CDATA[(mysqli_query|pg_execute|pg_insert|pg_query|pg_select|pg_update|sqlite_query|msql_query|mssql_query|odbc_exec|fbsql_query|sybase_query|ibase_query|dbx_query|ingres_query|ifx_query|oci_parse|sqlsrv_query|maxdb_query|db2_exec)]]></match>
<level value="8"/>
Expand Down
2 changes: 2 additions & 0 deletions tests/vulnerabilities/ことがあ/v.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?php
eval($_GET['a']);

0 comments on commit c098a7e

Please sign in to comment.