Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added insecure flag to skip SSL verification for Jira and Confluence #17

Merged
merged 1 commit into from
Jun 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/n0s1/config/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ general_params:
report_format: "n0s1"
timeout: null
limit: null
insecure: false

comment_params:
bot_name: "n0s1 bot"
Expand Down
9 changes: 5 additions & 4 deletions src/n0s1/controllers/confluence_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,20 @@ def set_config(self, config):
EMAIL = config.get("email", "")
TOKEN = config.get("token", "")
TIMEOUT = config.get("timeout", -1)
VERIFY_SSL = not config.get("insecure", False)
self._url = SERVER
self._user = EMAIL
self._password = TOKEN
if EMAIL and len(EMAIL) > 0:
if TIMEOUT and TIMEOUT > 0:
self._client = Confluence(url=SERVER, username=EMAIL, password=TOKEN, timeout=TIMEOUT)
self._client = Confluence(url=SERVER, verify_ssl=VERIFY_SSL, username=EMAIL, password=TOKEN, timeout=TIMEOUT)
else:
self._client = Confluence(url=SERVER, username=EMAIL, password=TOKEN)
self._client = Confluence(url=SERVER, verify_ssl=VERIFY_SSL, username=EMAIL, password=TOKEN)
else:
if TIMEOUT and TIMEOUT > 0:
self._client = Confluence(url=SERVER, token=TOKEN, timeout=TIMEOUT)
self._client = Confluence(url=SERVER, verify_ssl=VERIFY_SSL, token=TOKEN, timeout=TIMEOUT)
else:
self._client = Confluence(url=SERVER, token=TOKEN)
self._client = Confluence(url=SERVER, verify_ssl=VERIFY_SSL, token=TOKEN)
return self.is_connected()

def get_name(self):
Expand Down
10 changes: 6 additions & 4 deletions src/n0s1/controllers/jira_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,18 @@ def set_config(self, config):
EMAIL = config.get("email", "")
TOKEN = config.get("token", "")
TIMEOUT = config.get("timeout", -1)
VERIFY_SSL = not config.get("insecure", False)
options = {"verify": VERIFY_SSL}
if EMAIL and len(EMAIL) > 0:
if TIMEOUT and TIMEOUT > 0:
self._client = JIRA(SERVER, basic_auth=(EMAIL, TOKEN), timeout=TIMEOUT)
self._client = JIRA(SERVER, options=options, basic_auth=(EMAIL, TOKEN), timeout=TIMEOUT)
else:
self._client = JIRA(SERVER, basic_auth=(EMAIL, TOKEN))
self._client = JIRA(SERVER, options=options, basic_auth=(EMAIL, TOKEN))
else:
if TIMEOUT and TIMEOUT > 0:
self._client = JIRA(SERVER, token_auth=TOKEN, timeout=TIMEOUT)
self._client = JIRA(SERVER, options=options, token_auth=TOKEN, timeout=TIMEOUT)
else:
self._client = JIRA(SERVER, token_auth=TOKEN)
self._client = JIRA(SERVER, options=options, token_auth=TOKEN)
return self.is_connected()

def get_name(self):
Expand Down
12 changes: 12 additions & 0 deletions src/n0s1/n0s1.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,12 @@ def init_argparse() -> argparse.ArgumentParser:
type=str,
help="The limit of the number of pages to return per HTTP request"
)
parent_parser.add_argument(
"--insecure",
dest="insecure",
action="store_true",
help="Insecure mode. Ignore SSL certificate verification.",
)
subparsers = parser.add_subparsers(
help="Subcommands", dest="command", metavar="COMMAND"
)
Expand Down Expand Up @@ -497,8 +503,14 @@ def main(callback=None):
else:
limit = cfg.get("general_params", {}).get("limit", None)

if args.insecure:
insecure = bool(args.insecure)
else:
insecure = cfg.get("general_params", {}).get("insecure", False)

controler_config["timeout"] = timeout
controler_config["limit"] = limit
controler_config["insecure"] = insecure

TOKEN = None
SERVER = None
Expand Down