Skip to content

Add extractTerraformChanges filter plugin #726

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

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

Add extractTerraformChanges filter plugin #726

wants to merge 2 commits into from

Conversation

vim-zz
Copy link
Collaborator

@vim-zz vim-zz commented May 28, 2025

Analyzes Terraform HCL file changes to extract highest privilege level from modified JIT access configurations. Returns 'rw' for read-write, 'ro' for read-only, or null if no JIT objects modified.

✨ PR Description

The purpose and impact of these changes is to introduce a new GitStream filter called extractTerraformChanges that analyzes Terraform HCL file changes to extract the highest privilege level from modified JIT access configurations.

Main changes:

  • Implements a new filter function to parse Terraform HCL diffs and identify privilege changes in JIT objects
  • Adds documentation, examples, and test cases for the new extractTerraformChanges filter
  • Creates a configuration file for using the filter in GitStream automations

Generated by LinearB AI and added by gitStream.
AI-generated content may contain inaccuracies. Please verify before using. We'd love your feedback! 🚀

Analyzes Terraform HCL file changes to extract highest privilege
level from modified JIT access configurations. Returns 'rw' for
read-write, 'ro' for read-only, or null if no JIT objects modified.
Copy link

@orca-security-us orca-security-us bot left a comment

Choose a reason for hiding this comment

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

Orca Security Scan Summary

Status Check Issues by priority
Passed Passed Infrastructure as Code high 0   medium 0   low 0   info 0 View in Orca
Passed Passed SAST high 0   medium 2   low 0   info 0 View in Orca
Passed Passed Secrets high 0   medium 0   low 0   info 0 View in Orca
Passed Passed Vulnerabilities high 0   medium 0   low 0   info 0 View in Orca
🛡️ The following SAST misconfigurations have been detected
NAME FILE
medium Dynamic File Path Construction from User Input Can Lead to Path Traversal Attacks ...aformChanges/test.js View in code
medium Dynamic File Path Construction from User Input Can Lead to Path Traversal Attacks ...aformChanges/test.js View in code

Copy link
Contributor

gitstream-cm bot commented May 28, 2025

Please mark which AI tools you used for this PR by checking the appropriate boxes:

  • GitHub Copilot
  • Cursor
  • ChatGPT
  • Tabnine
  • JetBrains AI Assistant
  • VSCode IntelliCode
  • Claude
  • Gemini
  • Other AI tool
  • No AI tools were used

Tip: If you want to avoid this comment in the future, you can add a label of the format 🤖 ai-* when creating your PR.

gitstream-cm[bot]

This comment was marked as outdated.

@gitstream-cm gitstream-cm bot requested a review from BenLloydPearson May 28, 2025 13:40
@gitstream-cm gitstream-cm bot requested a review from a team May 28, 2025 13:41
Copy link

@orca-security-us orca-security-us bot left a comment

Choose a reason for hiding this comment

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

Orca Security Scan Summary

Status Check Issues by priority
Passed Passed Infrastructure as Code high 0   medium 0   low 0   info 0 View in Orca
Passed Passed SAST high 0   medium 3   low 0   info 0 View in Orca
Passed Passed Secrets high 0   medium 0   low 0   info 0 View in Orca
Passed Passed Vulnerabilities high 0   medium 0   low 0   info 0 View in Orca
🛡️ The following SAST misconfigurations have been detected
NAME FILE
medium Dynamic File Path Construction from User Input Can Lead to Path Traversal Attacks ...aformChanges/test.js View in code
medium Dynamic File Path Construction from User Input Can Lead to Path Traversal Attacks ...aformChanges/test.js View in code
medium Dynamic File Path Construction from User Input Can Lead to Path Traversal Attacks ...aformChanges/test.js View in code

Copy link
Contributor

@gitstream-cm gitstream-cm bot left a comment

Choose a reason for hiding this comment

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

✨ PR Review

The PR introduces a new filter plugin for analyzing Terraform HCL changes to extract privilege levels from JIT configurations. The implementation includes comprehensive parsing logic with good error handling and test coverage.

1 issues detected:

🐞 Bug - Deleted lines are incorrectly tracked with the new file's line numbers instead of the original file's line numbers

Details: The diff parsing logic has an error in line number tracking. When processing deleted lines (lines starting with '-'), the code adds them to changedLines but doesn't increment currentLine. This causes incorrect line number mapping between the diff and the original content, leading to wrong JIT object detection.
File: plugins/filters/extractTerraformChanges/index.js (72-72)

Generated by LinearB AI and added by gitStream.
AI-generated content may contain inaccuracies. Please verify before using. We'd love your feedback! 🚀

Copy link
Collaborator

@MishaKav MishaKav left a comment

Choose a reason for hiding this comment

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

Amazing 🎉

@gitstream-cm gitstream-cm bot requested a review from a team May 28, 2025 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants