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

Add jiraCollaborationGUID parameter to workflow body builders for Jir… #537

Merged
merged 1 commit into from
Dec 15, 2024

Conversation

kooomix
Copy link
Contributor

@kooomix kooomix commented Dec 15, 2024

User description

…a integration


PR Type

Enhancement


Description

  • Added support for JIRA collaboration GUID in workflow body builders:
    • Added jiraCollaborationGUID parameter to build_securityRisk_workflow_body() and build_vulnerabilities_workflow_body()
    • Updated workflow creation calls to pass JIRA collaboration GUID from environment variables
    • Added collaborationGUID field to JIRA ticket identifiers configuration
  • The changes enable proper JIRA integration by including collaboration identification

Changes walkthrough 📝

Relevant files
Enhancement
jira_workflows.py
Add JIRA collaboration GUID support to workflow builders 

tests_scripts/workflows/jira_workflows.py

  • Added jiraCollaborationGUID parameter to workflow body builder
    functions
  • Updated workflow creation calls to include JIRA collaboration GUID
    from environment
  • Modified JIRA notification configuration to include collaboration GUID
    field
  • +6/-4     

    💡 PR-Agent usage: Comment /help "your question" on any pull request to receive relevant information

    Copy link

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
    🧪 PR contains tests
    🔒 Security concerns

    Environment Variable Exposure:
    The code retrieves sensitive JIRA configuration details (site ID, project ID, collaboration GUID) from environment variables and includes them in workflow bodies. While using environment variables is a common practice, ensure these values are properly masked in logs and error messages to prevent accidental exposure.

    ⚡ Recommended focus areas for review

    Input Validation
    The new jiraCollaborationGUID parameter is added but there's no validation of this input parameter. Consider adding validation to ensure it's not null/empty and has the correct format.

    Error Handling
    The get_env() calls for JIRA environment variables are not wrapped in any error handling. Missing environment variables could cause runtime failures.

    Copy link

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Score
    Possible issue
    Validate required environment variables before using them to prevent runtime failures

    Add validation to ensure the JIRA_COLLABORATION_GUID environment variable exists and
    is not empty before using it in workflow creation to prevent potential runtime
    errors.

    tests_scripts/workflows/jira_workflows.py [52]

    -workflow_body = self.build_securityRisk_workflow_body(name=SECURITY_RISKS_WORKFLOW_NAME_JIRA + self.cluster, severities=SEVERITIES_MEDIUM, jiraCollaborationGUID=get_env("JIRA_COLLABORATION_GUID"), siteId=get_env("JIRA_SITE_ID"), projectId=get_env("JIRA_PROJECT_ID"), cluster=self.cluster, namespace=self.namespace, category=SECURITY_RISKS, securityRiskIDs=SECURITY_RISKS_ID, issueTypeId=get_env("JIRA_ISSUE_TYPE_ID"))
    +jira_collab_guid = get_env("JIRA_COLLABORATION_GUID")
    +if not jira_collab_guid:
    +    raise ValueError("JIRA_COLLABORATION_GUID environment variable is required but not set")
    +workflow_body = self.build_securityRisk_workflow_body(name=SECURITY_RISKS_WORKFLOW_NAME_JIRA + self.cluster, severities=SEVERITIES_MEDIUM, jiraCollaborationGUID=jira_collab_guid, siteId=get_env("JIRA_SITE_ID"), projectId=get_env("JIRA_PROJECT_ID"), cluster=self.cluster, namespace=self.namespace, category=SECURITY_RISKS, securityRiskIDs=SECURITY_RISKS_ID, issueTypeId=get_env("JIRA_ISSUE_TYPE_ID"))
    • Apply this suggestion
    Suggestion importance[1-10]: 8

    Why: The suggestion adds crucial validation for a required environment variable that could cause runtime failures if missing, especially important since JIRA_COLLABORATION_GUID is a new mandatory parameter being added in this PR.

    8

    Copy link

    Failed to generate code suggestions for PR

    @kooomix kooomix merged commit 25835ca into master Dec 15, 2024
    2 checks passed
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    2 participants