Skip to content

Commit

Permalink
Add settings:
Browse files Browse the repository at this point in the history
* DD_SEARCH_SCM_TYPE - flag to enable/disable scm_type search
* DD_DEFAULT_SCM_TYPE - default value for scm_type
* DD_JIRA_CONNECT_METHOD - import path for jira connect method
  • Loading branch information
Kurochkin Dmitriy Vadimovich committed Dec 20, 2024
1 parent 874d493 commit 4d4af37
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
4 changes: 2 additions & 2 deletions dojo/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3191,13 +3191,13 @@ def get_file_path_with_link(self):
def get_scm_type(self):
# extract scm type from product custom field 'scm-type'

if hasattr(self.test.engagement, "product"):
if settings.SEARCH_SCM_TYPE and hasattr(self.test.engagement, "product"):
dojo_meta = DojoMeta.objects.filter(product=self.test.engagement.product, name="scm-type").first()
if dojo_meta:
st = dojo_meta.value.strip()
if st:
return st.lower()
return ""
return settings.DEFAULT_SCM_TYPE

def scm_public_prepare_base_link(self, uri):
# scm public (https://scm-domain.org) url template for browse is:
Expand Down
19 changes: 19 additions & 0 deletions dojo/settings/settings.dist.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,12 @@
# For HTTP requests, how long connection is open before timeout
# This settings apply only on requests performed by "requests" lib used in Dojo code (if some included lib is using "requests" as well, this does not apply there)
DD_REQUESTS_TIMEOUT=(int, 30),
# When set to True, searches for scm-type in DojoMeta
DD_SEARCH_SCM_TYPE=(bool, True),
# When scm-type is not found for a product or DD_SEARCH_SCM_TYPE is False returns the specified value
DD_DEFAULT_SCM_TYPE=(str, ""),
# When set, use this method for connect to jira
DD_JIRA_CONNECT_METHOD=(str, ""),
)


Expand Down Expand Up @@ -1802,6 +1808,19 @@ def saml2_attrib_map_format(dict):
# ------------------------------------------------------------------------------
REQUESTS_TIMEOUT = env("DD_REQUESTS_TIMEOUT")

SEARCH_SCM_TYPE = env("DD_SEARCH_SCM_TYPE")

if env("DD_DEFAULT_SCM_TYPE") in ["github", "gitlab", "gitea", "codeberg", "bitbucket", "bitbucket-standalone"]:
DEFAULT_SCM_TYPE = env("DD_DEFAULT_SCM_TYPE")
else:
DEFAULT_SCM_TYPE = ""

# Example:
# For file /app/dojo/jira_link/helper_jira.py with method connect_to_jira_by_token(jira_server, _, jira_token)
# DD_JIRA_CONNECT_METHOD = dojo.jira_link.helper_jira.connect_to_jira_by_token
if env("DD_JIRA_CONNECT_METHOD"):
JIRA_CONNECT_METHOD = env("DD_JIRA_CONNECT_METHOD")

# ------------------------------------------------------------------------------
# Ignored Warnings
# ------------------------------------------------------------------------------
Expand Down

0 comments on commit 4d4af37

Please sign in to comment.