boman-cli 1.9__tar.gz → 2.0__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: 1.9
3
+ Version: 2.0
4
4
  Summary: CLI tool of boman.ai
5
5
  Home-page: https://boman.ai
6
6
  Author: Sumeru Software Solutions Pvt. Ltd.
@@ -83,6 +83,10 @@ Example: boman-cli -a run -zap_session_script ./session.js
83
83
 
84
84
  ### Release Note:
85
85
 
86
+ ### V2.0
87
+
88
+ - New scan added: Container scan.
89
+ - New Tool added for SCA scan type.
86
90
 
87
91
  ### V1.9:
88
92
 
@@ -68,6 +68,10 @@ Example: boman-cli -a run -zap_session_script ./session.js
68
68
 
69
69
  ### Release Note:
70
70
 
71
+ ### V2.0
72
+
73
+ - New scan added: Container scan.
74
+ - New Tool added for SCA scan type.
71
75
 
72
76
  ### V1.9:
73
77
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: boman-cli
3
- Version: 1.9
3
+ Version: 2.0
4
4
  Summary: CLI tool of boman.ai
5
5
  Home-page: https://boman.ai
6
6
  Author: Sumeru Software Solutions Pvt. Ltd.
@@ -83,6 +83,10 @@ Example: boman-cli -a run -zap_session_script ./session.js
83
83
 
84
84
  ### Release Note:
85
85
 
86
+ ### V2.0
87
+
88
+ - New scan added: Container scan.
89
+ - New Tool added for SCA scan type.
86
90
 
87
91
  ### V1.9:
88
92
 
@@ -49,6 +49,8 @@ class Config:
49
49
 
50
50
  sca_present = None
51
51
  sca_lang = None
52
+ sca_type= None
53
+ sca_target= None
52
54
 
53
55
  sca_scan_status = None
54
56
  sca_upload_status = None
@@ -113,6 +115,38 @@ class Config:
113
115
 
114
116
  log_level = "INFO"
115
117
 
116
- version = 'v1.9'
118
+ version = 'v2.0'
117
119
 
118
120
  boman_config_file = 'boman.yaml'
121
+
122
+ osv_supported_files = [
123
+ "buildscript-gradle.lockfile",
124
+ "gradle.lockfile",
125
+ "pom.xml",
126
+ "go.mod",
127
+ "mix.lock",
128
+ "pubspec.lock",
129
+ "conan.lock",
130
+ "package-lock.json",
131
+ "pnpm-lock.yaml",
132
+ "yarn.lock",
133
+ "composer.lock",
134
+ "Pipfile.lock",
135
+ "poetry.lock",
136
+ "requirements.txt",
137
+ "pdm.lock",
138
+ "Cargo.lock",
139
+ "Gemfile.lock",
140
+ "renv.lock"
141
+ ]
142
+
143
+ #Container scan
144
+ con_scan_present=None
145
+ con_scan_build_dir=None
146
+ con_scan_message=None
147
+ con_scan_response=None
148
+ con_scan_errors=None
149
+ con_scan_upload_status=None
150
+ con_scan_status=None
151
+ con_scan_type=None
152
+ con_scan_target=None
@@ -0,0 +1,98 @@
1
+ import requests
2
+ # from base_logger import logging
3
+ # from Config import Config
4
+ from bomancli.base_logger import logging
5
+ from bomancli.Config import Config
6
+ from bomancli import utils as Utils
7
+ import os
8
+ import json
9
+
10
+
11
+
12
+ ## function to authorize and get the images form SAAS --------------------------------------------------------
13
+ def authorize():
14
+
15
+ url = Config.boman_url+"/api/app/authorize"
16
+
17
+ if Config.sca_present:
18
+ if Config.sca_type == "directory":
19
+ file_present = False
20
+ for filename in Config.osv_supported_files:
21
+ if Config.sca_target is None:
22
+ if recursive_file_present_check(Config.sca_build_dir,filename):
23
+ file_present =True
24
+ Config.sca_target= ""
25
+ logging.info(f"Boman has found the dependency file: {filename} in the path: {os.path.join(Config.sca_build_dir,Config.sca_target)}")
26
+ break
27
+ else:
28
+ if recursive_file_present_check(os.path.join(Config.sca_build_dir,Config.sca_target),filename):
29
+ file_present =True
30
+ Config.sca_target= os.path.join(Config.sca_target,filename)
31
+ logging.info(f"Boman has found the dependency file: {filename} in the path: {os.path.join(Config.sca_build_dir,Config.sca_target)}")
32
+ break
33
+ if file_present:
34
+ Config.sca_lang ="osv"
35
+ else:
36
+ logging.warning(f"Boman has not found the dependency file")
37
+ if Config.sca_target is not None:
38
+ Config.sca_build_dir = os.path.join(Config.sca_build_dir,Config.sca_target)
39
+ logging.info(f"build dir: {Config.sca_build_dir} ")
40
+ Config.sca_lang = "owasp dependency check"
41
+ elif file_present_check(os.path.join(Config.sca_build_dir,Utils.remove_leading_slash(Config.sca_target))):
42
+ Config.sca_lang ="osv"
43
+ else:
44
+ logging.error(f"No such file found: {os.path.join(Config.sca_build_dir,Utils.remove_leading_slash(Config.sca_target))}")
45
+ exit(4)
46
+
47
+ logging.info(f"Boman opted for: {Config.sca_lang} scan")
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}
50
+ headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
51
+ try:
52
+ res = requests.post(url, json=data, headers=headers)
53
+ #print('req:', json.dumps(data))
54
+ #print('res:',json.loads(res.content))
55
+ except requests.ConnectionError:
56
+ logging.error("Can't connect to the Server while authorizing, Please check your Internet connection.")
57
+ exit(1) #server/saas error
58
+ else:
59
+ if res.status_code == 200:
60
+ try:
61
+ json_response = json.loads(res.content)
62
+ logging.info('Authentication Done')
63
+ except:
64
+ logging.info('Authentication Failure')
65
+ try:
66
+ Config.dast_response = json_response['data']['dast']
67
+ Config.sast_response = json_response['data']['sast']
68
+ Config.sca_response = json_response['data']['sca']
69
+ Config.secret_scan_response = json_response['data']['secret_scan']
70
+ Config.scan_token = json_response['data']['scan_token']
71
+ Config.scan_name = json_response['data']['scan_name']
72
+ Config.con_scan_response = json_response['data']['cs']
73
+
74
+ return 1
75
+ except:
76
+ logging.error('Problem when authenticating with server, Check with boman.ai team id scan doesnt completed')
77
+ #uploadLogs() this wont work because the scan is not initated.
78
+ exit(1) ## server error
79
+
80
+
81
+ elif res.status_code == 401:
82
+ logging.error('Unauthorized Access. Check the tokens')
83
+ else:
84
+ logging.error(f'Boman returned status code: {res.status_code}({res.reason})')
85
+ exit(2) ##auth error
86
+
87
+ # whether file present in the directory or not
88
+ def recursive_file_present_check(root_dir, file_name):
89
+ for root, dirs, files in os.walk(root_dir):
90
+ if file_name in files:
91
+ return os.path.join(root, file_name)
92
+ return None
93
+
94
+ # whether file present in the directory or not
95
+ def file_present_check(filename):
96
+ if os.path.isfile(filename):
97
+ return True
98
+ return False