Skip to content

failed to get git::https://github.com/<org-name>/Intern-Demo-Infrastructure?ref=v1.0.0 because of Cmd('git') failed due to: exit code(128) #187

@zameer712

Description

@zameer712

Hi Team,

Hope you are doing well.

iam unable to authenticate to the repository for downloading the modules from a specific repo not sure whats the problem

Below is my workflow which is being used from our side

name: 🚀 Prisma Cloud IaC Scan

description: Run Prisma Cloud Infrastructure as Code (IaC) scan and comment results on PR.

inputs:
  PCC_IAC_URL:
    description: 'Prisma Cloud Compute IaC URL'
    required: true
  api-key:
    description: 'Prisma Cloud Compute API Key'
    required: true
  directory:
    description: 'Directory to scan'
    required: true
  softFail:
    description: 'Soft fail flag'
    required: false
    default: 'true'
  quiet:
    description: 'Quiet mode flag'
    required: false
    default: 'true'
  downloadExternalModules:
    description: 'Download external modules flag'
    required: false
    default: 'true'
  logLevel:
    description: 'Log level (optional)'
    required: false
    default: 'DEBUG'
  token:
    description: 'GitHub token'
    required: true
    default: 'secrets.EE_CHECKOUT_TOKEN'

runs:
  using: composite
  steps:
  
    - name: 🛠 Configure Git for Private Repository Access
      run: |
       git config --global url."https://oauth2:${{ inputs.token }}@github.com".insteadOf https://github.com
      shell: bash

    - name: 🔍 Run Prisma Scan - Bridgecrew
      id: checkov
      uses: bridgecrewio/checkov-action@master
      env:
        PRISMA_API_URL: ${{ inputs.PCC_IAC_URL }}
        GITHUB_OVERRIDE_URL: true
      with:
        api-key: ${{ inputs.api-key }}
        directory: ${{ inputs.directory }}
        soft_fail: true
        quiet: true
        download_external_modules: true
        GITHUB_PAT: ${{ inputs.token }}
        output_format: sarif
        output_file_path: results.sarif

    - name: 💬 Add Comment on PR
      id: comment
      uses: actions/github-script@v7
      with:
        script: |
          const fs = require('fs');
          const path = 'results.sarif';

          // Ensure the file exists and is not a directory
          if (!fs.existsSync(path) || fs.lstatSync(path).isDirectory()) {
            console.log("Warning: SARIF file does not exist or is a directory. Skipping comment.");
            return;
          }

          const rawData = fs.readFileSync(path, 'utf8');  // Specify encoding to avoid binary issues
          const report = JSON.parse(rawData);

          const summaryTable = report.runs[0]?.results?.map((result) => {
            const ruleId = result.ruleId || "N/A";
            const level = result.level || "N/A";
            const message = result.message?.text || "No message";
            const fileUri = result.locations?.[0]?.physicalLocation?.artifactLocation?.uri || "N/A";
            return { ruleId, level, message, fileUri };
          }) || [];

          const levelCounts = summaryTable.reduce((acc, item) => {
            acc[item.level] = (acc[item.level] || 0) + 1;
            return acc;
          }, {});

          const errorData = summaryTable.filter(item => item.level === 'error');

          const message = `
          🛡 **Prisma Scan Summary** 🛡

          | 🔹 Level | 🔹 Total Occurrences |
          |---------|------------------|
          ${Object.keys(levelCounts).map(level => `| ${level} | ${levelCounts[level]} |`).join('\n')}
          | **Total** | ${Object.values(levelCounts).reduce((total, count) => total + count, 0)} |

          | 🚨 Rule ID | ⚠️ Level | 📝 Message | 📂 File URI |
          |-----------|--------|---------|------------|
          ${errorData.map(item => `| ${item.ruleId} | ${item.level} | ${item.message} | ${item.fileUri} |`).join('\n')}

          ⚠️ _Note: Only "error" level issues are displayed here. Check the Security tab for the full report._
          `;

          github.rest.issues.createComment({
            issue_number: context.issue.number,
            owner: context.repo.owner,
            repo: context.repo.repo,
            body: message
          });


    - name: 📤 Upload SARIF Report to GitHub
      uses: github/codeql-action/upload-sarif@v3
      if: success() || failure()  # ✅ Corrected conditional statement
      with:
        sarif_file: results.sarif

Below is the error we are getting

2025-02-04 06:33:02,244 [MainThread  ] [WARNI]  failed to get git::https://github.com/<org-name>/Intern-Demo-Infrastructure?ref=v1.0.0 because of Cmd('git') failed due to: exit code(128)
  cmdline: git clone -v --depth=1 -b v1.0.0 -- https://github.com/<org-name>/Intern-Demo-Infrastructure /github/workspace/infrastructure/environments/interns/interns_infra_training/.external_modules/github.com/<org-name>/Intern-Demo-Infrastructure/v1.0.0
  stderr: 'Cloning into '/github/workspace/infrastructure/environments/interns/interns_infra_training/.external_modules/github.com/<org_name>/Intern-Demo-Infrastructure/v1.0.0'...
remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/<org-name>/Intern-Demo-Infrastructure/'
'
2025-02-04 06:33:02,354 [MainThread  ] [WARNI]  failed to get git::https://github.com/<org-name>/Intern-Demo-Infrastructure?ref=v1.0.0 because of Cmd('git') failed due to: exit code(128)
  cmdline: git clone -v --depth=1 -b v1.0.0 -- https://github.com/<org-name>/Intern-Demo-Infrastructure /github/workspace/infrastructure/environments/interns/interns_infra_training/.external_modules/github.com/<org_name>/Intern-Demo-Infrastructure/v1.0.0
  stderr: 'Cloning into '/github/workspace/infrastructure/environments/interns/interns_infra_training/.external_modules/github.com/<org-name>/Intern-Demo-Infrastructure/v1.0.0'...
remote: Support for password authentication was removed on August 13, 2021.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions