Skip to content

Commit 4c59524

Browse files
author
Simon Siegert
committed
Add option to read list of files from an input file
1 parent eec4cf2 commit 4c59524

File tree

3 files changed

+21
-13
lines changed

3 files changed

+21
-13
lines changed

README.md

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,26 @@ Based on https://github.com/uber/py-find-injection.
66

77

88
# Usage
9-
``` shell
9+
```
1010
$ python bin/pyInjection.py --help
11-
usage: pyInjection.py [-h] [-v] [-j] [-q] [files [files ...]]
11+
usage: pyInjection.py [-h] [-v] [-i INPUT] [-j] [-s] [-q] [files [files ...]]
1212
1313
Look for patterns in python source files that might indicate SQL injection or
1414
other vulnerabilities
1515
1616
positional arguments:
17-
files files to check or '-' for standard in
17+
files files to check or '-' for standard in
1818
1919
optional arguments:
20-
-h, --help show this help message and exit
21-
-v, --version show program's version number and exit
22-
-j, --json print output in JSON
23-
-q, --quiet Do not print error statistics
24-
25-
Exit status is 0 if all files are okay, 1 if any files have an error. Errors
26-
are printed to standard out
20+
-h, --help show this help message and exit
21+
-v, --version show program's version number and exit
22+
-i INPUT, --input INPUT
23+
path to a file containing a list of files to check,
24+
each file in a line
25+
-j, --json print output in JSON
26+
-s, --stdin read from standard in, passed files are ignored
27+
-q, --quiet do not print error statistics
28+
29+
Exit status is 0 if all files are okay, 1 if any files have an error. Found
30+
vulnerabilities are printed to standard out
2731
```

bin/pyInjection.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import sys
77
import fileinput
88
import json
9-
version_info = (0, 1, 3)
9+
version_info = (0, 1, 4)
1010
__version__ = '.'.join(map(str, version_info))
1111

1212

@@ -133,6 +133,7 @@ def create_parser():
133133
)
134134
parser.add_argument('-v', '--version', action='version', version='%(prog)s ' + __version__)
135135
parser.add_argument('files', nargs='*', help='files to check or \'-\' for standard in')
136+
parser.add_argument('-i', '--input', help='path to a file containing a list of files to check, each file in a line')
136137
parser.add_argument('-j', '--json', action='store_true', help='print output in JSON')
137138
parser.add_argument('-s', '--stdin', action='store_true', help='read from standard in, passed files are ignored')
138139
parser.add_argument('-q', '--quiet', action='store_true', help='do not print error statistics')
@@ -144,8 +145,11 @@ def main():
144145
parser = create_parser()
145146
args = parser.parse_args()
146147

147-
if not (args.files or args.stdin):
148+
if not (args.files or args.stdin or args.input):
148149
parser.error('incorrect number of arguments')
150+
if args.input:
151+
args.files = map(lambda x: x.strip('\n'),
152+
open(args.input, 'r').readlines())
149153
if args.stdin:
150154
args.files = ['-']
151155

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
setup(
55
name="pyInjection",
6-
version="0.1.3",
6+
version="0.1.4",
77
author="James Brown",
88
author_email="jbrown@uber.com",
99
url="https://github.com/simsieg/pyInjection",

0 commit comments

Comments
 (0)