diff --git a/.github/workflows/ai-code-review.yml b/.github/workflows/ai-code-review.yml index 2d970ba..27f5a92 100644 --- a/.github/workflows/ai-code-review.yml +++ b/.github/workflows/ai-code-review.yml @@ -21,6 +21,7 @@ permissions: {} jobs: code_review: + name: Code Review runs-on: cx-public-ubuntu-x64 permissions: contents: read @@ -28,6 +29,8 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 + with: + persist-credentials: false - name: Code Review uses: aidar-freeed/ai-codereviewer@a9a064dfa1db8c83f40ef63f6e247fa09c935ed6 #main-22.1.25 with: diff --git a/.github/workflows/cxone-scan-teams-notify.yml b/.github/workflows/cxone-scan-teams-notify.yml index cd3564e..db785d2 100644 --- a/.github/workflows/cxone-scan-teams-notify.yml +++ b/.github/workflows/cxone-scan-teams-notify.yml @@ -51,24 +51,35 @@ jobs: name: Notify Teams runs-on: cx-public-ubuntu-x64 if: always() + env: + REPOSITORY: ${{ inputs.repository }} + PR_NUMBER: ${{ inputs.pr_number }} + PR_URL: ${{ inputs.pr_url }} + CX_RESULT: ${{ inputs.cx_result }} + SERVER_URL: ${{ inputs.server_url }} + RUN_ID: ${{ inputs.run_id }} + REF_NAME: ${{ inputs.ref_name }} + ACTOR: ${{ inputs.actor }} + EVENT_NAME: ${{ inputs.event_name }} + TEAMS_WEBHOOK_URL: ${{ secrets.teams_webhook_url }} steps: - name: Notify Microsoft Teams run: | - REPO_NAME="${{ inputs.repository }}" + REPO_NAME="${REPOSITORY}" REPO_NAME="${REPO_NAME#*/}" - if [[ -n "${{ inputs.pr_number }}" ]]; then + if [[ -n "${PR_NUMBER}" ]]; then PR_SECTION=", { \"type\": \"TextBlock\", - \"text\": \"**Pull Request:** [#${{ inputs.pr_number }}](${{ inputs.pr_url }})\", + \"text\": \"**Pull Request:** [#${PR_NUMBER}](${PR_URL})\", \"wrap\": true }" else PR_SECTION="" fi - if [[ "${{ inputs.cx_result }}" == "success" ]]; then + if [[ "${CX_RESULT}" == "success" ]]; then COLOR="Good" TITLE="✅ ${REPO_NAME} - Checkmarx One Scan Succeeded" STATUS_TEXT="The Checkmarx One Scan job completed successfully." @@ -78,7 +89,7 @@ jobs: STATUS_TEXT="The Checkmarx One Scan job failed. Review the run for details." fi - RUN_URL="${{ inputs.server_url }}/${{ inputs.repository }}/actions/runs/${{ inputs.run_id }}" + RUN_URL="${SERVER_URL}/${REPOSITORY}/actions/runs/${RUN_ID}" curl -f -H 'Content-Type: application/json' -d "{ \"type\": \"message\", @@ -105,10 +116,10 @@ jobs: { \"type\": \"FactSet\", \"facts\": [ - {\"title\": \"Repository:\", \"value\": \"${{ inputs.repository }}\"}, - {\"title\": \"Branch:\", \"value\": \"${{ inputs.ref_name }}\"}, - {\"title\": \"Triggered By:\", \"value\": \"${{ inputs.actor }}\"}, - {\"title\": \"Event:\", \"value\": \"${{ inputs.event_name }}\"} + {\"title\": \"Repository:\", \"value\": \"${REPOSITORY}\"}, + {\"title\": \"Branch:\", \"value\": \"${REF_NAME}\"}, + {\"title\": \"Triggered By:\", \"value\": \"${ACTOR}\"}, + {\"title\": \"Event:\", \"value\": \"${EVENT_NAME}\"} ] } $PR_SECTION @@ -123,4 +134,4 @@ jobs: } } ] - }" "${{ secrets.teams_webhook_url }}" \ No newline at end of file + }" "${TEAMS_WEBHOOK_URL}" \ No newline at end of file diff --git a/.github/workflows/dispatch-workflow.yml b/.github/workflows/dispatch-workflow.yml index cf6ef58..95c9b59 100644 --- a/.github/workflows/dispatch-workflow.yml +++ b/.github/workflows/dispatch-workflow.yml @@ -50,12 +50,15 @@ jobs: steps: - name: Check Out Repository uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 + with: + persist-credentials: false - name: Check Out External Repository uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 with: repository: Checkmarx/plugins-release-workflow path: plugins-release-workflow + persist-credentials: false - name: Set Up Python uses: actions/setup-python@7f4fc3e22c37d6ff65e88745f38bd3157c663f7c # v4.9.1 @@ -90,12 +93,15 @@ jobs: steps: - name: Check Out Repository uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 + with: + persist-credentials: false - name: Check Out External Repository uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 with: repository: Checkmarx/plugins-release-workflow path: plugins-release-workflow + persist-credentials: false - name: Set Up Python uses: actions/setup-python@7f4fc3e22c37d6ff65e88745f38bd3157c663f7c # v4.9.1 @@ -130,12 +136,15 @@ jobs: steps: - name: Check Out Repository uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 + with: + persist-credentials: false - name: Check Out External Repository uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 with: repository: Checkmarx/plugins-release-workflow path: plugins-release-workflow + persist-credentials: false - name: Set Up Python uses: actions/setup-python@7f4fc3e22c37d6ff65e88745f38bd3157c663f7c # v4.9.1 @@ -172,12 +181,15 @@ jobs: steps: - name: Check Out Repository uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 + with: + persist-credentials: false - name: Check Out External Repository uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 with: repository: Checkmarx/plugins-release-workflow path: plugins-release-workflow + persist-credentials: false - name: Set Up Python uses: actions/setup-python@7f4fc3e22c37d6ff65e88745f38bd3157c663f7c # v4.9.1 diff --git a/.github/workflows/jira_close.yml b/.github/workflows/jira_close.yml index c02cd96..06713e4 100644 --- a/.github/workflows/jira_close.yml +++ b/.github/workflows/jira_close.yml @@ -17,11 +17,17 @@ on: AST_JIRA_USER_EMAIL: required: true +permissions: + contents: read + jobs: close_jira: + name: Close Jira runs-on: cx-public-ubuntu-x64 env: JIRA_URL: "https://checkmarx.atlassian.net" + REPO: ${{ inputs.repo }} + ISSUE_NUMBER: ${{ inputs.issue_number }} steps: - name: Jira Login uses: atlassian/gajira-login@ca13f8850ea309cf44a6e4e0c49d9aa48ac3ca4c # v3.0.0 @@ -33,10 +39,13 @@ jobs: - name: Extract Jira Issue Key id: extract_key uses: actions/github-script@10b53a9ec6c222bb4ce97aa6bd2b5f739696b536 # v4.2.0 + env: + REPO: ${{ inputs.repo }} + ISSUE_NUMBER: ${{ inputs.issue_number }} with: script: | - const [owner, repo] = "${{ inputs.repo }}".split('/'); - const issue_number = ${{ inputs.issue_number }}; + const [owner, repo] = process.env.REPO.split('/'); + const issue_number = parseInt(process.env.ISSUE_NUMBER); const comments = await github.issues.listComments({ owner, repo, issue_number }); const jiraRegex = /AST-\d{3,5}/; @@ -51,11 +60,16 @@ jobs: - name: Get current Jira status id: get_status + env: + JIRA_URL: https://checkmarx.atlassian.net + JIRA_USER_EMAIL: ${{ secrets.AST_JIRA_USER_EMAIL }} + JIRA_API_TOKEN: ${{ secrets.AST_JIRA_API_TOKEN }} + JIRA_KEY: ${{ steps.extract_key.outputs.jira_key }} run: | - RESPONSE=$(curl -s -u "${{ secrets.AST_JIRA_USER_EMAIL }}:${{ secrets.AST_JIRA_API_TOKEN }}" \ + RESPONSE=$(curl -s -u "${JIRA_USER_EMAIL}:${JIRA_API_TOKEN}" \ -X GET \ -H "Accept: application/json" \ - "${{ env.JIRA_URL }}/rest/api/3/issue/${{ steps.extract_key.outputs.jira_key }}") + "${JIRA_URL}/rest/api/3/issue/${JIRA_KEY}") STATUS=$(echo "$RESPONSE" | jq -r '.fields.status.name') echo "Current status is: $STATUS" diff --git a/.github/workflows/jira_notify.yml b/.github/workflows/jira_notify.yml index 1166955..7f38726 100644 --- a/.github/workflows/jira_notify.yml +++ b/.github/workflows/jira_notify.yml @@ -30,11 +30,21 @@ on: JIRA_FIELDS_OTHER: required: true +permissions: {} + jobs: notify_jira: + name: Notify Jira runs-on: cx-public-ubuntu-x64 + permissions: + issues: write # for creating comments on GitHub issues + pull-requests: write # for workflow-triggered by pull requests env: JIRA_URL: "https://checkmarx.atlassian.net/" + INPUT_TITLE: ${{ inputs.title }} + INPUT_BODY: ${{ inputs.body }} + INPUT_HTML_URL: ${{ inputs.html_url }} + INPUT_REPO: ${{ inputs.repo }} steps: - name: Jira Login uses: atlassian/gajira-login@ca13f8850ea309cf44a6e4e0c49d9aa48ac3ca4c #v3 @@ -46,7 +56,7 @@ jobs: - name: Determine Issue Type id: issue_type run: | - if [[ "${{ inputs.title }}" == *"[Bug]"* ]]; then + if [[ "${INPUT_TITLE}" == *"[Bug]"* ]]; then echo "IS_BUG=true" >> $GITHUB_ENV echo "Selected Issue Type: BUG" else @@ -64,10 +74,10 @@ jobs: id: extract_fields run: | # Extracting fields from the issue body - ISSUE_DESCRIPTION=$(echo "${{ inputs.body }}" | awk -v RS='' '/### What happened\?/{getline; print}') - ISSUE_VERSION=$(echo "${{ inputs.body }}" | awk -v RS='' '/### Version/{getline; print}') - ISSUE_OS=$(echo "${{ inputs.body }}" | awk -v RS='' '/### Operating System & Version/{getline; print}') - ISSUE_LOGS=$(echo "${{ inputs.body }}" | awk -v RS='' '/### Relevant log output/{getline; print}') + ISSUE_DESCRIPTION=$(echo "${INPUT_BODY}" | awk -v RS='' '/### What happened\?/{getline; print}') + ISSUE_VERSION=$(echo "${INPUT_BODY}" | awk -v RS='' '/### Version/{getline; print}') + ISSUE_OS=$(echo "${INPUT_BODY}" | awk -v RS='' '/### Operating System & Version/{getline; print}') + ISSUE_LOGS=$(echo "${INPUT_BODY}" | awk -v RS='' '/### Relevant log output/{getline; print}') # Printing extracted values to the workflow log echo "Extracted Fields:" @@ -86,15 +96,15 @@ jobs: - name: Format Jira Description id: format_description run: | - FORMATTED_DESCRIPTION="*Issue Title:* ${{ inputs.title }} \\\\" - FORMATTED_DESCRIPTION+="*Repository:* ${{ inputs.repo }} \\\\" + FORMATTED_DESCRIPTION="*Issue Title:* ${INPUT_TITLE} \\\\" + FORMATTED_DESCRIPTION+="*Repository:* ${INPUT_REPO} \\\\" FORMATTED_DESCRIPTION+="*What Happened:* $ISSUE_DESCRIPTION \\\\" FORMATTED_DESCRIPTION+="*Version:* $ISSUE_VERSION \\\\" FORMATTED_DESCRIPTION+="*Operating System & Version:* $ISSUE_OS \\\\" if [[ -n "$ISSUE_LOGS" ]]; then FORMATTED_DESCRIPTION+=" *Relevant Logs:*\n{code}$ISSUE_LOGS{code} \\\\" fi - FORMATTED_DESCRIPTION+="[View original issue|${{ inputs.html_url }}]" + FORMATTED_DESCRIPTION+="[View original issue|${INPUT_HTML_URL}]" echo "FORMATTED_DESCRIPTION=$FORMATTED_DESCRIPTION" >> $GITHUB_ENV @@ -105,7 +115,7 @@ jobs: with: project: AST issuetype: Task - summary: '${{ inputs.repo }} ${{ inputs.title }}' + summary: '${{ env.INPUT_REPO }} ${{ env.INPUT_TITLE }}' description: '${{ env.FORMATTED_DESCRIPTION }}' fields: "${{ secrets.JIRA_FIELDS_BUG }}" @@ -116,18 +126,23 @@ jobs: with: project: AST issuetype: Task - summary: '${{ inputs.repo }} ${{ inputs.title }}' + summary: '${{ env.INPUT_REPO }} ${{ env.INPUT_TITLE }}' description: '${{ env.FORMATTED_DESCRIPTION }}' fields: "${{ secrets.JIRA_FIELDS_OTHER }}" - name: Add comment to GitHub issue uses: actions/github-script@a3e7071a34d7e1f219a8a4de9a5e0a34d1ee1293 # v4.0.2 + env: + BUG_ISSUE: ${{ steps.create_jira_bug.outputs.issue }} + ENHANCEMENT_ISSUE: ${{ steps.create_jira_enhancement.outputs.issue }} + JIRA_URL: ${{ env.JIRA_URL }} with: script: | - issue_id = process.env.IS_BUG == 'true' ? "${{ steps.create_jira_bug.outputs.issue }}" : "${{ steps.create_jira_enhancement.outputs.issue }}" + const issue_id = process.env.IS_BUG == 'true' ? process.env.BUG_ISSUE : process.env.ENHANCEMENT_ISSUE; + const jiraUrl = process.env.JIRA_URL; github.issues.createComment({ issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, - body: 'Internal Jira issue: [' + issue_id + '](${{ env.JIRA_URL }}/browse/' + issue_id + ')' + body: 'Internal Jira issue: [' + issue_id + '](' + jiraUrl + '/browse/' + issue_id + ')' }) diff --git a/.github/workflows/release-notify.yml b/.github/workflows/release-notify.yml index 45b8081..232cfc4 100644 --- a/.github/workflows/release-notify.yml +++ b/.github/workflows/release-notify.yml @@ -35,17 +35,29 @@ on: MS_TEAMS_WEBHOOK_URL_SYPHER: required: true +permissions: + contents: read + jobs: notify-teams: + name: Notify Teams runs-on: cx-public-ubuntu-x64 + env: + INPUT_RELEASE_URL: ${{ inputs.release_url }} + INPUT_PRODUCT_NAME: ${{ inputs.product_name }} + INPUT_RELEASE_VERSION: ${{ inputs.release_version }} + INPUT_CLI_RELEASE_VERSION: ${{ inputs.cli_release_version }} + INPUT_JIRA_PRODUCT_NAME: ${{ inputs.jira_product_name }} steps: - name: Fetch Release Notes id: fetch_release_notes uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6.4.1 + env: + RELEASE_URL: ${{ inputs.release_url }} with: script: | - const releaseUrl = '${{ inputs.release_url }}'; + const releaseUrl = process.env.RELEASE_URL; const urlPattern = /https:\/\/github\.com\/([^\/]+)\/([^\/]+)\/releases\/tag\/(.+)/; const match = releaseUrl.match(urlPattern); if (!match) { @@ -61,17 +73,21 @@ jobs: - name: Sanitize Release Notes id: sanitize_release_notes + env: + RELEASE_NOTES: ${{ steps.fetch_release_notes.outputs.release_notes }} run: | - sanitized=$(echo "${{ steps.fetch_release_notes.outputs.release_notes }}" | sed '1{/^