Skip to content

feat: terraform parser option to set current working directory #8909

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

Merged
merged 2 commits into from
May 27, 2025

Conversation

Emyrk
Copy link
Contributor

@Emyrk Emyrk commented May 23, 2025

Description

Terraform path.cwd intends to be the directory terraform was executed from. This value should be controllable by the caller. Especially when using in memory file systems, the actual filesystem is irrelevant.

In the my use case, ideally I would not leak any information of the actual file system of the host executing the terraform scanning.

Checklist

  • I've read the guidelines for contributing to this repository.
  • I've followed the conventions in the PR title.
  • I've added tests that prove my fix is effective or that my feature works.
  • I've updated the documentation with the relevant information (if needed).
  • I've added usage information (if the PR introduces new options)
  • I've included a "before" and "after" example to the description (if the PR is a user interface change).

Terraform `path.cwd` intends to be the directory `terraform` was
executed from. This value should be controllable by the caller.
Especially when using in memory file systems, the actual filesystem
is irrelevant.
@Emyrk Emyrk requested review from simar7 and nikpivkin as code owners May 23, 2025 16:13
@@ -52,6 +52,9 @@ type Parser struct {
fsMap map[string]fs.FS
configsFS fs.FS
skipPaths []string
// cwd is optional, if provided it will be used instead of 'os.Getwd'
// for populating 'path.cwd' in terraform
cwd *string
Copy link
Contributor

Choose a reason for hiding this comment

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

Why can't an empty string mean no cwd?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can do that 👍, just wanted it to be an explicit opt in.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@nikpivkin Fixed 👍

@Emyrk Emyrk requested a review from nikpivkin May 27, 2025 16:03
@simar7 simar7 added this pull request to the merge queue May 27, 2025
Merged via the queue into aquasecurity:main with commit 8939451 May 27, 2025
12 checks passed
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