Skip to content

Conversation

@cx-artur-ribeiro
Copy link
Contributor

@cx-artur-ribeiro cx-artur-ribeiro commented Nov 19, 2025

Reason for Proposed Changes

KICS experienced OOM errors when scanning large Terraform codebases due to:

  • O(n²) complexity in variable resolution (rescanning all .tf files for every file parsed);
  • Memory estimation based only on file count, ignoring actual file sizes;

Proposed Changes

  • Added directory-level caching for Terraform variable resolution;
  • Thread-safe cache reduces complexity from O(n²) to O(n);
  • Eliminates redundant file scans (e.g., 247 terraform files: from 61,009 → 247 reads);
  • Enhanced file statistics with LOC tracking;
  • Provides per-platform statistics;
  • Fixed secrets inspector to not fail scan when secrets queires timeout;

I submit this contribution under the Apache-2.0 license.

@cx-artur-ribeiro cx-artur-ribeiro self-assigned this Nov 19, 2025
@gitguardian
Copy link

gitguardian bot commented Nov 19, 2025

⚠️ GitGuardian has uncovered 1 secret following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

🔎 Detected hardcoded secret in your pull request
GitGuardian id GitGuardian status Secret Commit Filename
21271469 Triggered Generic Password 5fd3a69 assets/queries/terraform/azure/unrestricted_sql_server_access/test/negative5.tf View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secret safely. Learn here the best practices.
  3. Revoke and rotate this secret.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

@github-actions github-actions bot added the terraform Terraform query label Nov 19, 2025
@github-actions
Copy link
Contributor

kics-logo

KICS version: v2.1.13

Category Results
CRITICAL CRITICAL 0
HIGH HIGH 0
MEDIUM MEDIUM 0
LOW LOW 0
INFO INFO 0
TRACE TRACE 0
TOTAL TOTAL 0
Metric Values
Files scanned placeholder 1
Files parsed placeholder 1
Files failed to scan placeholder 0
Total executed queries placeholder 47
Queries failed to execute placeholder 0
Execution time placeholder 0

@cx-artur-ribeiro cx-artur-ribeiro marked this pull request as ready for review December 2, 2025 15:31
@cx-artur-ribeiro cx-artur-ribeiro requested a review from a team as a code owner December 2, 2025 15:31
Copy link
Contributor

@cx-eduardo-semanas cx-eduardo-semanas left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@cx-rui-araujo cx-rui-araujo left a comment

Choose a reason for hiding this comment

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

@cx-artur-ribeiro check my comment pls

mergeMaps(variablesMap, variables)
}
}
cacheKey = currentPath + "|" + terraformVarsPath
Copy link
Contributor

Choose a reason for hiding this comment

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

If the cache key is the full path, it can sometimes become quite large. Should this be a hash instead?
Please ask the rest of the team for their opinions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

terraform Terraform query

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants