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

fix(non-linux): Bash environment variables in arguments not expanded + Add trace log level #645

Merged
merged 10 commits into from
Mar 13, 2024

Conversation

MaxymVlasov
Copy link
Collaborator

@MaxymVlasov MaxymVlasov commented Mar 12, 2024

Put an x into the box if that apply:

  • This PR introduces breaking change.
  • This PR fixes a bug.
  • This PR adds new functionality.
  • This PR enhances existing functionality.

Description of your changes

Fixes #638

How can we test changes

repos:
- repo: https://github.com/antonbabenko/pre-commit-terraform
  rev: c71b65619d78da05ea3be5f374fa3d679ed5c1c4
  hooks:
    - id: terraform_trivy
      args:
        - --args=--config-policy="/Users/${USER}/PATH_TO_CUSTOM_POLICY/"
      verbose: true

and run

  • pre-commit run -a
  • PCT_LOG=trace pre-commit run -a

@MaxymVlasov MaxymVlasov changed the title fix(non-linux): Bash environment variables in arguments not expanded fix(non-linux): Bash environment variables in arguments not expanded. Add trace log level Mar 12, 2024
@MaxymVlasov MaxymVlasov changed the title fix(non-linux): Bash environment variables in arguments not expanded. Add trace log level fix(non-linux): Bash environment variables in arguments not expanded + Add trace log level Mar 12, 2024
@MaxymVlasov MaxymVlasov changed the title fix(non-linux): Bash environment variables in arguments not expanded + Add trace log level fix(non-linux): Bash environment variables in arguments not expanded + Add trace log level Mar 12, 2024
@MaxymVlasov MaxymVlasov changed the title fix(non-linux): Bash environment variables in arguments not expanded + Add trace log level fix(non-linux): Bash environment variables in arguments not expanded + Add trace log level for the throne of debugging God Mar 12, 2024
@MaxymVlasov MaxymVlasov changed the title fix(non-linux): Bash environment variables in arguments not expanded + Add trace log level for the throne of debugging God fix(non-linux): Bash environment variables in arguments not expanded + Add trace log level Mar 12, 2024
@yermulnik
Copy link
Collaborator

  • ? is not supported in bash regex outside Linux.

Kinda the same GNU vs POSIX implementation of regex 😢

@robinbowes
Copy link
Contributor

Is there perhaps some other way to achieve what is going on there with the regex?

What's the purpose of the common::parse_and_export_env_vars function?

hooks/_common.sh Outdated Show resolved Hide resolved
@yermulnik
Copy link
Collaborator

Is there perhaps some other way to achieve what is going on there with the regex?

This PR corrects the questionable regex and this also eliminates diff between Linux/non-Linux implementations as far as I understand.

What's the purpose of the common::parse_and_export_env_vars function?

https://github.com/antonbabenko/pre-commit-terraform#all-hooks-usage-of-environment-variables-in---argspre-commit doesn't provide an option to use env vars with hook configs and hence Max invented this solution to improve experience for pre-commit-terraform users 😺

Co-authored-by: George L. Yermulnik <yz@yz.kiev.ua>
@MaxymVlasov MaxymVlasov merged commit a2a2990 into master Mar 13, 2024
6 checks passed
@MaxymVlasov MaxymVlasov deleted the GH-638/GH-562/better_logging branch March 13, 2024 20:47
antonbabenko pushed a commit that referenced this pull request Mar 13, 2024
## [1.88.2](v1.88.1...v1.88.2) (2024-03-13)

### Bug Fixes

* **non-linux:** Bash environment variables in arguments not expanded + Add `trace` log level ([#645](#645)) ([a2a2990](a2a2990))
@antonbabenko
Copy link
Owner

This PR is included in version 1.88.2 🎉

MaxymVlasov added a commit that referenced this pull request Mar 14, 2024
…+ Add `trace` log level (#645)

---------

Co-authored-by: George L. Yermulnik <yz@yz.kiev.ua>
MaxymVlasov pushed a commit that referenced this pull request Mar 14, 2024
## [1.88.2](v1.88.1...v1.88.2) (2024-03-13)

### Bug Fixes

* **non-linux:** Bash environment variables in arguments not expanded + Add `trace` log level ([#645](#645)) ([a2a2990](a2a2990))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/macOS bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bash environment variable expansion not working for trivy
4 participants