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

Calculate line number correctly in multi-line strings #676

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

nimrodkor
Copy link
Contributor

  • Please check if the PR fulfills these requirements
  • Tests for the changes have been added
  • Docs have been added / updated
  • All CI checks are green
  • What kind of change does this PR introduce?

This is a bugfix for a case where a multi-line yaml string has secrets in a line which is not the very first one.

  • What is the current behavior?

Today, the error is pointed at the beginning of the string, even if the secret itself is in some row down the file.

  • What is the new behavior (if this is a feature change)?
    It will point to the actual line with the secret in it

  • Does this PR introduce a breaking change?
    No

  • Other information:
    Already working on our (bridgecrewio) fork :)

@jpdakran
Copy link
Member

Hi. Please merge master to your branch to re-run CI.

line=line,
context=code_snippet,
):
if determine_file_type(filename) == FileType.YAML and secret.secret_value:
Copy link
Member

Choose a reason for hiding this comment

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

Have you looked at yaml transformer? Yaml files are transformed according to this transformer. So any changes should be done here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @jpdakran !
Yes I have, it seems it merges the lines into 1 which makes sense from scanning perspective, but not from finding perspective. Otherwise, the secret's line is the first one, even though the secret is on the third line.
The yaml transformer doesn't retain a mapping of this...

@lorenzodb1
Copy link
Contributor

hi @nimrodkor 😄 could you please merge master into your branch?

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.

3 participants