local_file Fix Block
January 6, 2024 ยท View on GitHub
The local_file fix block in the grept tool is used to write a specified content into one or more local files. This can be used to enforce certain file content rules.
Attributes
rule_ids: The ID list of the rules this fix is associated with. Any rule check failure would trigger this fix.paths: A list of file paths where the content should be written.content: The content to be written to the files.mode: (Optional) The mode to set if creating a new file. Defaults to0644.
Exported Attributes
The local_file fix block does not export any attributes.
Example
Here's an example of how to use the local_file fix block in your configuration file:
fix "local_file" "example" {
rule_ids = ["example_rule"]
paths = ["/path/to/file1", "/path/to/file2"]
content = "Example content"
}
This will write the text "Example content" to the files at /path/to/file1 and /path/to/file2 if the rule with ID example_rule fails.