Skip to content

Commit 0255e26

Browse files
authored
Minor fixes for working with custom base domain (#23)
1 parent 0980358 commit 0255e26

File tree

4 files changed

+27
-5
lines changed

4 files changed

+27
-5
lines changed

socketsecurity/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
__author__ = 'socket.dev'
2-
__version__ = '1.0.22'
2+
__version__ = '1.0.24'

socketsecurity/core/__init__.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,8 @@
4545
org_slug = None
4646
all_new_alerts = False
4747
security_policy = {}
48+
allow_unverified_ssl = False
4849
log = logging.getLogger("socketdev")
49-
# log_format = "%(asctime)s %(funcName)20s() %(message)s"
50-
# logging.basicConfig(format=log_format)
5150
log.addHandler(logging.NullHandler())
5251

5352
socket_globs = {
@@ -164,13 +163,17 @@ def do_request(
164163
'User-Agent': f'SocketPythonCLI/{__version__}',
165164
"accept": "application/json"
166165
}
166+
verify = False
167+
if allow_unverified_ssl:
168+
verify = True
167169
response = requests.request(
168170
method.upper(),
169171
url,
170172
headers=headers,
171173
data=payload,
172174
files=files,
173-
timeout=timeout
175+
timeout=timeout,
176+
verify=verify
174177
)
175178
output_headers = headers.copy()
176179
output_headers['Authorization'] = "API_KEY_REDACTED"
@@ -215,7 +218,16 @@ class Core:
215218
request_timeout: int
216219
reports: list
217220

218-
def __init__(self, token: str, base_api_url=None, request_timeout=None, enable_all_alerts=False):
221+
def __init__(
222+
self,
223+
token: str,
224+
base_api_url: str = None,
225+
request_timeout: int = None,
226+
enable_all_alerts: bool = False,
227+
allow_unverified: bool = False
228+
):
229+
global allow_unverified_ssl
230+
allow_unverified_ssl = allow_unverified
219231
self.token = token + ":"
220232
encode_key(self.token)
221233
self.socket_date_format = "%Y-%m-%dT%H:%M:%S.%fZ"

socketsecurity/core/git_interface.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from git import Repo
22
from socketsecurity.core import log
3+
import urllib.parse
34

45

56
class Git:
@@ -15,6 +16,7 @@ def __init__(self, path: str):
1516
self.repo_name = self.repo.remotes.origin.url.split('.git')[0].split('/')[-1]
1617
try:
1718
self.branch = self.head.reference
19+
urllib.parse.unquote(str(self.branch))
1820
except Exception as error:
1921
self.branch = None
2022
log.debug(error)

socketsecurity/socketcli.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,13 @@
113113
default=False
114114
)
115115

116+
parser.add_argument(
117+
'--allow-unverified',
118+
help='Allow unverified SSL Connections',
119+
action='store_true',
120+
default=False
121+
)
122+
116123
parser.add_argument(
117124
'--enable-json',
118125
help='Enable json output of results instead of table formatted',
@@ -235,6 +242,7 @@ def main_code():
235242
disable_security_issue = arguments.disable_security_issue
236243
ignore_commit_files = arguments.ignore_commit_files
237244
disable_blocking = arguments.disable_blocking
245+
allow_unverified = arguments.allow_unverified
238246
if disable_blocking:
239247
global blocking_disabled
240248
blocking_disabled = True

0 commit comments

Comments
 (0)