Skip to content

Commit b3e8116

Browse files
author
Jakob Maier
committed
implmented multiple components in args
1 parent 1650f60 commit b3e8116

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

examples/client/get_project_vulnerabilites_as_csv.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,16 @@
2929
def strip_newline(str):
3030
return str.replace('\r', '').replace('\n', '')
3131

32+
def match_component(selected_components, component):
33+
if (len(selected_components) == 0):
34+
return True
35+
36+
for selected in selected_components:
37+
if (re.search(selected, component, re.IGNORECASE)):
38+
return True
39+
40+
return False
41+
3242
def main():
3343
program_name = os.path.basename(sys.argv[0])
3444
parser = argparse.ArgumentParser(prog=program_name, usage="%(prog)s [options]", description="Automated Assessment")
@@ -40,8 +50,11 @@ def main():
4050
parser.add_argument("--components", required=False, help="component names, comma seperated without space")
4151
args = parser.parse_args()
4252

43-
component = args.component
44-
components = args.components.sqlit(',')
53+
components = args.components.split(',') if args.components != None else []
54+
55+
if (args.component != None):
56+
components.append(args.component)
57+
4558
projectname = args.project
4659
projectversion = args.version
4760
output = args.output if args.output != None else "output.csv"
@@ -68,7 +81,8 @@ def main():
6881
for vulnverable_component in bd.get_resource('vulnerable-components', version):
6982
componentName = vulnverable_component["componentName"]
7083

71-
if (component == None or re.search(component, componentName, re.IGNORECASE)):
84+
#if (component == None or re.search(component, componentName, re.IGNORECASE)):
85+
if (match_component(components, componentName)):
7286
componentVersion = vulnverable_component["componentVersionName"]
7387
remediation = vulnverable_component['vulnerabilityWithRemediation']
7488

0 commit comments

Comments
 (0)