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

1.3.x Upgrade is Breaking Pipeline with Custom working_directory #88

Open
hi-artem opened this issue Nov 3, 2022 · 0 comments
Open

Comments

@hi-artem
Copy link

hi-artem commented Nov 3, 2022

We have a huge monorepo with multiple entrypoints for Terraform. The 1.3.x release is breaking our pipeline.

The example of pipeline:

name: iac-scan
on:
  pull_request:
jobs:
  changed-files:
    name: Get changed files
    runs-on: ubuntu-latest
    outputs:
      matrix: ${{ steps.set-matrix.outputs.matrix }}
    steps:
      - name: Clone repo
        uses: actions/checkout@master

      - name: Get changed dir-names
        id: changed-files
        uses: hi-artem/changed-files@main
        with:
          dir_names: "true"
          json: "true"
          max_fetch_depth: "2147483647"
          files: |
            terraform/**
      - name: List all changed files
        run: |
          echo '${{ steps.changed-files.outputs.all_changed_files }}'
      - id: set-matrix
        run: echo "matrix={\"files\":${{ steps.changed-files.outputs.all_changed_files }}}" >> "$GITHUB_OUTPUT"

  tfsec:
    name: IaC Scan with tfsec
    runs-on: ubuntu-latest
    needs: [changed-files]
    strategy:
      matrix: ${{ fromJSON(needs.changed-files.outputs.matrix) }}
      max-parallel: 4
      fail-fast: false
    steps:
      - name: Clone repo
        uses: actions/checkout@master
      - name: tfsec
        uses: aquasecurity/tfsec-pr-commenter-action@v1.3.1
        with:
          tfsec_args: --custom-check-dir .tfsec
          soft_fail_commenter: true
          github_token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
          working_directory: ${{  matrix.files }}

It works fine if we pin commenter to 1.2.0, but the latest (1.3.1) is acting weird. Here's an example of logs:

+ tfsec --out=results.json --format=json --soft-fail --soft-fail terraform/aws/develop/shared
1 file(s) written: results.json
+ commenter
Starting the github commenter
Working in repository terraform
Working in PR 9999
TFSec found 21 issues
Working in GITHUB_WORKSPACE /github/workspace/
Preparing comment for violation of rule aws-ec2-enable-at-rest-encryption in terraform/aws/develop/shared/terraform/aws/develop/shared/test.tf
Ignoring - change not part of the current PR
Preparing comment for violation of rule aws-ec2-enable-at-rest-encryption in terraform/aws/develop/shared/terraform/aws/develop/shared/test.tf
Ignoring - change not part of the current PR
Preparing comment for violation of rule aws-ec2-enforce-http-token-imds in terraform/aws/develop/shared/terraform/aws/develop/shared/test.tf
Ignoring - change not part of the current PR
Preparing comment for violation of rule aws-ec2-enforce-http-token-imds in terraform/aws/develop/shared/terraform/aws/develop/shared/test.tf
Ignoring - change not part of the current PR
# blablabla and they all are ignored!

It appaers to append the working directory to filename twice! For example, terraform/aws/develop/shared/terraform/aws/develop/shared/test.tf should be terraform/aws/develop/shared/test.tf.

@hi-artem hi-artem changed the title 1.3.0 Upgrade is Breaking Pipeline with Custom working_directory 1.3.x Upgrade is Breaking Pipeline with Custom working_directory Nov 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant