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

feat(azure): Add get resource names for azure_pipelines #3798

Merged
merged 16 commits into from
Nov 7, 2022

Conversation

arielkru
Copy link
Contributor

@arielkru arielkru commented Nov 6, 2022

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Description

For Azure pipelines, create a report with a formatted resource name indicating the path to the error path in the file.
So if the error comes from the second step in the FailSetSecretVariable job:

jobs:
- job: FailSetSecretVariable
  pool:
    vmImage: 'ubuntu-20.04'
  steps:
  - bash: |
      echo "##vso[task.setvariable variable=normal_variable;]something"
      echo "##vso[task.setvariable variable=secret_variable;issecret=true]super-secret"
  - powershell: |
      Write-Host "##vso[task.setvariable variable=normal_variable;]something"
      Write-Host "##vso[task.setvariable variable=secret_variable;issecret=true]super-secret"

The resource name would be:
/azure-pipelines.yaml:jobs.FailSetSecretVariable.steps[1]

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my feature, policy, or fix is effective and works
  • New and existing tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@arielkru arielkru marked this pull request as ready for review November 7, 2022 10:45
Copy link
Contributor

@Eliran-Turgeman Eliran-Turgeman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome 🔥
Had one comment

Copy link
Contributor

@nimrodkor nimrodkor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice @arielkru !

checkov/azure_pipelines/runner.py Outdated Show resolved Hide resolved
Copy link
Contributor

@gruebel gruebel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice work 🍸

checkov/azure_pipelines/runner.py Outdated Show resolved Hide resolved
Copy link
Contributor

@gruebel gruebel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🍹


def _get_resource_from_code_block(block_to_inspect: dict[str, Any], inspected_key: str | None) -> str | None:
if block_to_inspect[START_LINE] <= start_line <= end_line <= block_to_inspect[END_LINE]:
block_name = block_to_inspect.get('displayName',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pattern matching of Python 3.10 would be great here 😄 good enough for now 👍

@arielkru arielkru merged commit 87f8ae8 into master Nov 7, 2022
@arielkru arielkru deleted the get_resource_azure_pipelines branch November 7, 2022 14:08
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

Successfully merging this pull request may close these issues.

5 participants