Add Terraform/OpenTofu state file scanning (--tfstate) - #61
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
--tfstate <path>to both subcommands, building an assessment from a local Terraform or OpenTofu state file instead of a live cloud account. No credentials, no API calls, nothing leaves the machine.Also available via
--configusingproviderDetails.tfstatePath.What changes
core/utils_tfstate.py— parses state format v4 (rejecting v1–v3 with a message pointing atterraform state pull), flattens to one record per instance socount/for_eachexpansions are exact, maps Terraform types to services viatf_code, and aggregates intoresource_inventory.region/locationattribute first, then the region field of the resource's ownarn. Referenced ARNs (stream_arn,kms_key_arn) are never used; they can point at another region or account.Security
State files hold generated passwords, connection strings and keys in plain text. Instance
attributesare never copied anywhere: only address, type, location and count leave the state. In place of the raw API dump written by live assessments, tfstate mode writesraw_data/tfstate_manifest.json. Only the file's basename is recorded, and only the region field is taken from an ARN — the AWS account id is never extracted. Verified by grepping every report artifact against secret-like values harvested from the source states.