Skip to content

Commit 74ddaf5

Browse files
author
Evell Lam
committed
Check for injections in Session and Cursor aliases
Print errors on ci build but do not fail
1 parent f91c137 commit 74ddaf5

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

py_find_injection/__init__.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def check_execute(self, node):
7777

7878
def visit_Call(self, node):
7979
function_name = stringify(node.func)
80-
if function_name.lower() in ('session.execute', 'cursor.execute'):
80+
if function_name.lower() in ('session.execute', 'cursor.execute', 'conn.execute', 'trans.execute', 'pg.execute', 'db.execute'):
8181
node.args[0].parent = node
8282
node_error = self.check_execute(node.args[0])
8383
if node_error:
@@ -122,6 +122,7 @@ def main():
122122
epilog='Exit status is 0 if all files are okay, 1 if any files have an error. Errors are printed to stdout'
123123
)
124124
parser.add_argument('--version', action='version', version='%(prog)s ' + __version__)
125+
parser.add_argument('--ci', action='store', required=False)
125126
parser.add_argument('files', nargs='+', help='Files to check')
126127
args = parser.parse_args()
127128

@@ -133,7 +134,12 @@ def main():
133134
errors.extend(these_errors)
134135
if errors:
135136
print '%d total errors' % len(errors)
136-
return 1
137+
if args.ci:
138+
print "CI build"
139+
return 0
140+
else:
141+
print "Pre-commit Checks"
142+
return 1
137143
else:
138144
return 0
139145

0 commit comments

Comments
 (0)