boman-cli 2.0__tar.gz → 2.1.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: boman-cli
3
- Version: 2.0
3
+ Version: 2.1.1
4
4
  Summary: CLI tool of boman.ai
5
5
  Home-page: https://boman.ai
6
6
  Author: Sumeru Software Solutions Pvt. Ltd.
@@ -83,11 +83,15 @@ Example: boman-cli -a run -zap_session_script ./session.js
83
83
 
84
84
  ### Release Note:
85
85
 
86
+ ### V2.1
87
+ - New scan added: SBOM.
88
+
86
89
  ### V2.0
87
90
 
88
91
  - New scan added: Container scan.
89
92
  - New Tool added for SCA scan type.
90
93
 
94
+
91
95
  ### V1.9:
92
96
 
93
97
  - [Bug fix] Updated the Upload Logs success message
@@ -68,11 +68,15 @@ Example: boman-cli -a run -zap_session_script ./session.js
68
68
 
69
69
  ### Release Note:
70
70
 
71
+ ### V2.1
72
+ - New scan added: SBOM.
73
+
71
74
  ### V2.0
72
75
 
73
76
  - New scan added: Container scan.
74
77
  - New Tool added for SCA scan type.
75
78
 
79
+
76
80
  ### V1.9:
77
81
 
78
82
  - [Bug fix] Updated the Upload Logs success message
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: boman-cli
3
- Version: 2.0
3
+ Version: 2.1.1
4
4
  Summary: CLI tool of boman.ai
5
5
  Home-page: https://boman.ai
6
6
  Author: Sumeru Software Solutions Pvt. Ltd.
@@ -83,11 +83,15 @@ Example: boman-cli -a run -zap_session_script ./session.js
83
83
 
84
84
  ### Release Note:
85
85
 
86
+ ### V2.1
87
+ - New scan added: SBOM.
88
+
86
89
  ### V2.0
87
90
 
88
91
  - New scan added: Container scan.
89
92
  - New Tool added for SCA scan type.
90
93
 
94
+
91
95
  ### V1.9:
92
96
 
93
97
  - [Bug fix] Updated the Upload Logs success message
@@ -25,6 +25,7 @@ class Config:
25
25
  sast_upload_status = None
26
26
  sast_message = None
27
27
  sast_errors = None
28
+ sast_ignore = False
28
29
 
29
30
  dast_present = None
30
31
  dast_target = None
@@ -56,6 +57,8 @@ class Config:
56
57
  sca_upload_status = None
57
58
  sca_message = None
58
59
  sca_errors = None
60
+ sca_ignore = False
61
+ sca_exclude_paths=None
59
62
 
60
63
  app_token = None
61
64
  customer_token = None
@@ -115,7 +118,7 @@ class Config:
115
118
 
116
119
  log_level = "INFO"
117
120
 
118
- version = 'v2.0'
121
+ version = 'v2.1.1'
119
122
 
120
123
  boman_config_file = 'boman.yaml'
121
124
 
@@ -149,4 +152,14 @@ class Config:
149
152
  con_scan_upload_status=None
150
153
  con_scan_status=None
151
154
  con_scan_type=None
152
- con_scan_target=None
155
+ con_scan_target=None
156
+
157
+ #sbom
158
+ sbom_present=None
159
+ sbom_build_dir=None
160
+ sbom_message=None
161
+ sbom_response=None
162
+ sbom_errors=None
163
+ sbom_upload_status=None
164
+ sbom_scan_status=None
165
+ sbom_target=None
@@ -46,7 +46,7 @@ def authorize():
46
46
 
47
47
  logging.info(f"Boman opted for: {Config.sca_lang} scan")
48
48
  logging.info('Authenticating with boman server')
49
- data = {'app_token': Config.app_token, 'customer_token': Config.customer_token, 'sast':Config.sast_present,"dast":Config.dast_present,"dast_type":Config.dast_type,"dast_auth_enabled":Config.dast_auth_present,"sast_langs":Config.sast_lang,"sca":Config.sca_present,"sca_langs":Config.sca_lang,"sca_scan_type":Config.sca_type,"secret_scan":Config.secret_scan_present,'container_scan': Config.con_scan_present,'container_scan_type': Config.con_scan_type}
49
+ data = {'app_token': Config.app_token, 'customer_token': Config.customer_token, 'sast':Config.sast_present,"dast":Config.dast_present,"dast_type":Config.dast_type,"dast_auth_enabled":Config.dast_auth_present,"sast_langs":Config.sast_lang,"sca":Config.sca_present,"sca_langs":Config.sca_lang,"sca_scan_type":Config.sca_type,"secret_scan":Config.secret_scan_present,'container_scan': Config.con_scan_present,'container_scan_type': Config.con_scan_type,"sbom":Config.sbom_present}
50
50
  headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
51
51
  try:
52
52
  res = requests.post(url, json=data, headers=headers)
@@ -69,7 +69,8 @@ def authorize():
69
69
  Config.secret_scan_response = json_response['data']['secret_scan']
70
70
  Config.scan_token = json_response['data']['scan_token']
71
71
  Config.scan_name = json_response['data']['scan_name']
72
- Config.con_scan_response = json_response['data']['cs']
72
+ Config.con_scan_response = json_response['data']['cs']
73
+ Config.sbom_response = json_response['data']['sbom']
73
74
 
74
75
  return 1
75
76
  except:
@@ -125,6 +125,12 @@ def runImage(data=None,type=None):
125
125
 
126
126
 
127
127
  if type == 'SAST':
128
+ if Config.sast_ignore:
129
+ if Utils.copy_file('.bomanignore','.semgrepignore'):
130
+ logging.info("Files and Folders to be ignored is added to .semgrepignore file")
131
+ else:
132
+ logging.error(".bomanignore file was not found")
133
+ exit(4)
128
134
  target_file = Config.sast_target
129
135
  Utils.checkImageAlreadyExsist(docker_image)
130
136
 
@@ -220,7 +226,8 @@ def runImage(data=None,type=None):
220
226
 
221
227
 
222
228
  try:
223
-
229
+ if Config.sast_ignore:
230
+ os.remove('.semgrepignore')
224
231
  if will_generate_output == 1:
225
232
  #logging.info('WILL GENERATE OUTPUT')
226
233
  if uploadReport(output_file,tool_name,tool_id,scan_details_id,'SAST'):
@@ -446,7 +453,12 @@ def runImage(data=None,type=None):
446
453
  container_output = docker.containers.run(docker_image, command_line, volumes={Config.sca_build_dir: {
447
454
  'bind': data['bind']}}, user=uid)
448
455
  logging.info('[SUCCESS]: %s Scan Completed',tool_name)
449
- else:
456
+ else:
457
+ if Config.sca_ignore:
458
+ Config.sca_exclude_files = Utils.read_bomanignore('.bomanignore')
459
+ if Config.sca_exclude_files:
460
+ command_line = f'{command_line} {Config.sca_exclude_files}'
461
+ logging.info('Comment for SCA with ignore %s',command_line)
450
462
  Config.build_dir = Config.sca_build_dir
451
463
  container_output = docker.containers.run(docker_image, command_line, volumes={Config.sca_build_dir: {
452
464
  'bind': data['bind']}}, user=uid)
@@ -535,7 +547,48 @@ def runImage(data=None,type=None):
535
547
  msg = 'Error recorded while uploading the report'
536
548
  Utils.logError(msg,str(e))
537
549
 
550
+ if type == 'sbom':
551
+ Utils.checkImageAlreadyExsist(docker_image)
552
+ logging.info('Running %s',tool_name)
553
+
554
+ try:
555
+ Config.build_dir = Config.sbom_build_dir
556
+ command_line = "% s" % command_line.format(target = 'src/')
557
+ container_output = docker.containers.run(docker_image, command_line, volumes={Config.sbom_build_dir: {
558
+ 'bind': data['bind']}}, user=uid)
559
+ logging.info('[SUCCESS]: %s Scan Completed',tool_name)
560
+ Config.sbom_message ='SBOM scan completed'
561
+ Config.sbom_scan_status ='Completed'
562
+ except errors.ContainerError as exc:
563
+ logging.error('Some Error recorded while scanning %s',tool_name)
564
+ logging.error('%s',str(exc))
565
+ msg='\n The following error has been recorded while scanning sca'
566
+ Config.sbom_scan_status ='Completed'
567
+ Config.sbom_errors ='Some Error recorded while scanning [',str(exc),']'
568
+ Utils.logError(msg,str(exc))
569
+
570
+ try:
571
+ if will_generate_output == 1:
572
+ logging.info('Uploading %s to the server',output_file)
573
+ if uploadReport(output_file,tool_name,tool_id,scan_details_id,'sbom'):
574
+ Config.sbom_scan_status ='Completed'
575
+ Config.sbom_upload_status = 'Completed'
576
+ Config.sbom_message ='Scan Completed'
577
+ else:
578
+ Config.sbom_scan_status ='Failed'
579
+ Config.sbom_upload_status = 'Failed'
580
+ Config.sbom_message ='Error occured while uploading the report, Please check the cli logs'
581
+ else:
582
+ logging.error('Cant upload files to the server',tool_name)
583
+ Config.sbom_message ='Cant upload files to the server for SBOM,Please check your directory for the files.'
538
584
 
585
+ except EnvironmentError as e:
586
+ logging.error('Error recorded while uploading the report %s',tool_name)
587
+ logging.error('%s',str(e))
588
+ Config.sbom_message ='Error recorded while uploading the report of SBOM, Please check your directory for the files.' ## need to change logic here -- MM
589
+ msg = 'Error recorded while uploading the report'
590
+ Utils.logError(msg,str(e))
591
+
539
592
 
540
593
  #### function to upload the test report to the server with other data -- MM ------------------------------------
541
594
  def uploadReport(filename,toolname,tool_id,scan_details_id,type):
@@ -563,6 +616,9 @@ def uploadReport(filename,toolname,tool_id,scan_details_id,type):
563
616
  elif type =="container_scan":
564
617
  message = Config.con_scan_message
565
618
  errors = Config.con_scan_errors
619
+ elif type =="sbom":
620
+ message = Config.sbom_message
621
+ errors = Config.sbom_errors
566
622
  except:
567
623
  message = 'NA'
568
624
  errors = 'NA'
@@ -743,7 +799,7 @@ def main():
743
799
 
744
800
  init()
745
801
  Validation.yamlValidation()
746
- if Config.secret_scan_present == True or Config.sast_present is True or Config.dast_present is True or Config.sca_present is True or Config.con_scan_present is True:
802
+ if Config.secret_scan_present == True or Config.sast_present is True or Config.dast_present is True or Config.sca_present is True or Config.con_scan_present is True or Config.sbom_present:
747
803
  Utils.testServer()
748
804
  else:
749
805
  content = Auth.authorize()
@@ -882,6 +938,20 @@ def main():
882
938
  runImage(data=data,type='container_scan')
883
939
  else:
884
940
  logging.info('Ignoring Container Scan')
941
+
942
+ if Config.sbom_present is True:
943
+ logging.info("Preparing SBOM requirements")
944
+
945
+ for data in Config.sbom_response:
946
+
947
+ if data['scan_status'] == 0 :
948
+ logging.info('No SBOM Configuration found from SaaS')
949
+ logging.info('Ignoring SBOM')
950
+ else:
951
+ runImage(data=data,type='sbom')
952
+ else:
953
+ logging.info('Ignoring SBOM')
954
+
885
955
  exitFunction()
886
956
  return 1
887
957
 
@@ -328,6 +328,16 @@ def showSummary():
328
328
  logging.info('SCAN MESSAGE : %s', Config.con_scan_message)
329
329
  logging.info('-------------------------------------')
330
330
 
331
+ logging.info('-------- SBOM SCAN STATUS --------- ')
332
+ if Config.sbom_present:
333
+ logging.info('SCAN STATUS: %s',Config.sbom_scan_status)
334
+ logging.info('UPLOAD STATUS: %s',Config.sbom_upload_status)
335
+ logging.info('SCAN MESSAGE : %s', Config.sbom_message)
336
+
337
+ logging.info('ERRORS: %s',Config.sbom_errors)
338
+ else:
339
+ logging.info('SCAN MESSAGE : %s', Config.sbom_message)
340
+ logging.info('-------------------------------------')
331
341
 
332
342
 
333
343
 
@@ -879,4 +889,31 @@ def uploadLogs():
879
889
 
880
890
  def remove_leading_slash(s):
881
891
  # Check if the first character is a slash and remove it
882
- return s[1:] if s.startswith('/') else s
892
+ return s[1:] if s.startswith('/') else s
893
+
894
+ def read_bomanignore(file_path):
895
+ exclude_paths = []
896
+ try:
897
+ with open(file_path, 'r') as file:
898
+ for line in file:
899
+ # Skip comments and empty lines
900
+ line = line.strip()
901
+ if line and not line.startswith('#'):
902
+ full_command = " --exclude "+line
903
+ exclude_paths.append(full_command)
904
+ except FileNotFoundError:
905
+ logging.info(f"Error: {file_path} not found.")
906
+ return False
907
+ # Join the list into a space separated string
908
+ return ''.join(exclude_paths)
909
+
910
+ def copy_file(source_path, dest_path):
911
+ try:
912
+ with open(source_path, 'r') as source_file:
913
+ source_content = source_file.read()
914
+ with open(dest_path, 'w') as dest_file:
915
+ dest_file.write(source_content)
916
+ return True # Successfully copied
917
+ except FileNotFoundError:
918
+ logging.info(f"Error: {source_path} not found.")
919
+ return False # Source file not found
@@ -61,6 +61,13 @@ def yamlValidation():
61
61
  except KeyError:
62
62
  logging.info('work dir not specified in config, choosing the default sast working directory')
63
63
  Config.sast_build_dir = os.getcwd()+'/'
64
+
65
+ try:
66
+ logging.info('Ignoring file and folder check')
67
+ Config.sast_ignore = Config.config_data['SAST']['ignore_files']
68
+ except KeyError:
69
+ logging.info('ignore_files config was not found')
70
+
64
71
 
65
72
  #logging.info('snyk is choosen, and the env var declared was %s', str('s'))
66
73
 
@@ -170,6 +177,11 @@ def yamlValidation():
170
177
  # ##after sbom and lockfile type check
171
178
  # Config.sca_build_dir = os.getcwd()+'/'
172
179
 
180
+ try:
181
+ logging.info('Ignoring file and folder check')
182
+ Config.sca_ignore = Config.config_data['SCA']['ignore_files']
183
+ except KeyError:
184
+ logging.info('ignore_files config was not found')
173
185
 
174
186
  try:
175
187
  logging.info('Configuring target for SCA')
@@ -263,10 +275,27 @@ def yamlValidation():
263
275
  logging.warning('Container Scan is not properly configured. Cant read the "container_scan" configuration.')
264
276
  Config.con_scan_message ='Container Scan is not properly configured'
265
277
 
266
-
278
+ try:
279
+ if "SBOM" in Config.config_data:
280
+ if Config.config_data['SBOM']:
281
+ Config.sbom_present = True
282
+ Config.sbom_build_dir = os.getcwd()+"/"
283
+ logging.info('SBOM is properly configured and ready to scan')
284
+ else:
285
+ Config.sbom_present = False
286
+ logging.warning('SBOM is not properly configured. Cant read the "sbom" configuration.')
287
+ Config.sbom_message ='sbom is not properly configured'
288
+
289
+ else:
290
+ Config.sbom_present = False
291
+ logging.warning('SBOM is not properly configured. Cant read the "sbom" configuration.')
292
+ Config.sbom_message ='sbom is not properly configured'
293
+ except:
294
+ Config.sbom_present = False
295
+ logging.warning('SBOM is not properly configured. Cant read the "sbom" configuration.')
296
+ Config.sbom_message ='sbom is not properly configured'
267
297
 
268
-
269
-
298
+
270
299
 
271
300
  ## need to use lingudetect here, but the results are not trustable and misleading ------ MM -------------------
272
301
  def findLang():
@@ -1,6 +1,6 @@
1
1
  [metadata]
2
2
  environment = prod
3
- version = 2.0
3
+ version = 2.1.1
4
4
  name = boman-cli
5
5
  saas_base_url =
6
6
  https = //dashboard.boman.ai/
File without changes
File without changes