regula-wasi 3.2.2 → 3.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -0
- package/cli.js +3 -0
- package/index.d.ts +94 -0
- package/index.js +23 -4
- package/package.json +3 -1
- package/regula.wasm +0 -0
package/README.md
CHANGED
|
@@ -79,6 +79,9 @@ const result = await runRegula('./main.tf', {
|
|
|
79
79
|
include: ['./custom-rules/'],
|
|
80
80
|
only: ['FG_R00229'], // Only run specific rules
|
|
81
81
|
exclude: ['FG_R00100'], // Exclude specific rules
|
|
82
|
+
noBuiltIns: false, // Disable built-in rules (use only custom rules)
|
|
83
|
+
noIgnore: false, // Disable .gitignore filtering
|
|
84
|
+
varFiles: ['./prod.tfvars'], // Terraform variable files
|
|
82
85
|
});
|
|
83
86
|
|
|
84
87
|
// Check for failures
|
|
@@ -88,6 +91,18 @@ if (result.summary.rule_results.FAIL > 0) {
|
|
|
88
91
|
}
|
|
89
92
|
```
|
|
90
93
|
|
|
94
|
+
#### API Options
|
|
95
|
+
|
|
96
|
+
| Option | Type | Description |
|
|
97
|
+
|--------|------|-------------|
|
|
98
|
+
| `inputType` | string | Input type: `auto`, `tf`, `tf-plan`, `cfn`, `k8s`, `arm` |
|
|
99
|
+
| `include` | string[] | Additional rego rule files/directories to include |
|
|
100
|
+
| `only` | string[] | Only run these specific rule IDs |
|
|
101
|
+
| `exclude` | string[] | Exclude these specific rule IDs |
|
|
102
|
+
| `noBuiltIns` | boolean | Disable built-in rules (use only custom rules from `include`) |
|
|
103
|
+
| `noIgnore` | boolean | Disable .gitignore filtering |
|
|
104
|
+
| `varFiles` | string[] | Terraform variable files (.tfvars) to use |
|
|
105
|
+
|
|
91
106
|
### Prebuilt Binary
|
|
92
107
|
|
|
93
108
|
Download from [Releases](https://github.com/nonfx/regula/releases) for your platform.
|
package/cli.js
CHANGED
|
@@ -10,6 +10,9 @@ const __dirname = dirname(__filename);
|
|
|
10
10
|
|
|
11
11
|
const args = process.argv.slice(2);
|
|
12
12
|
|
|
13
|
+
// Note: preopens "/" is required because regula needs to read IaC files from
|
|
14
|
+
// any path the user specifies (including absolute paths like /home/user/terraform/).
|
|
15
|
+
// This is expected behavior for a CLI tool that processes user-specified file paths.
|
|
13
16
|
const wasi = new WASI({
|
|
14
17
|
version: "preview1",
|
|
15
18
|
args: ["regula", ...args],
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
export interface RegulaOptions {
|
|
2
|
+
/** Input type: auto, tf, tf-plan, cfn, k8s, arm */
|
|
3
|
+
inputType?: "auto" | "tf" | "tf-plan" | "cfn" | "k8s" | "arm";
|
|
4
|
+
/** Additional rego rule files/directories to include */
|
|
5
|
+
include?: string | string[];
|
|
6
|
+
/** Only run these specific rule IDs */
|
|
7
|
+
only?: string | string[];
|
|
8
|
+
/** Exclude these specific rule IDs */
|
|
9
|
+
exclude?: string | string[];
|
|
10
|
+
/** Disable built-in rules (use only custom rules from include) */
|
|
11
|
+
noBuiltIns?: boolean;
|
|
12
|
+
/** Disable .gitignore filtering */
|
|
13
|
+
noIgnore?: boolean;
|
|
14
|
+
/** Terraform variable files (.tfvars) to use */
|
|
15
|
+
varFiles?: string | string[];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface SourceLocation {
|
|
19
|
+
path: string;
|
|
20
|
+
line: number;
|
|
21
|
+
column: number;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface RuleResult {
|
|
25
|
+
controls: string[];
|
|
26
|
+
families: string[];
|
|
27
|
+
filepath: string;
|
|
28
|
+
input_type: string;
|
|
29
|
+
provider: string;
|
|
30
|
+
resource_id: string;
|
|
31
|
+
resource_type: string;
|
|
32
|
+
resource_tags: Record<string, unknown>;
|
|
33
|
+
rule_description: string;
|
|
34
|
+
rule_id: string;
|
|
35
|
+
rule_message: string;
|
|
36
|
+
rule_name: string;
|
|
37
|
+
rule_raw_result: boolean;
|
|
38
|
+
rule_remediation_doc?: string;
|
|
39
|
+
rule_result: "PASS" | "FAIL" | "WAIVED";
|
|
40
|
+
rule_severity: "Unknown" | "Informational" | "Low" | "Medium" | "High" | "Critical";
|
|
41
|
+
rule_summary: string;
|
|
42
|
+
source_location?: SourceLocation[];
|
|
43
|
+
active_waivers?: string[];
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface RegulaResult {
|
|
47
|
+
rule_results: RuleResult[];
|
|
48
|
+
summary: {
|
|
49
|
+
filepaths: string[];
|
|
50
|
+
rule_results: {
|
|
51
|
+
PASS: number;
|
|
52
|
+
FAIL: number;
|
|
53
|
+
WAIVED: number;
|
|
54
|
+
};
|
|
55
|
+
severities: {
|
|
56
|
+
Unknown: number;
|
|
57
|
+
Informational: number;
|
|
58
|
+
Low: number;
|
|
59
|
+
Medium: number;
|
|
60
|
+
High: number;
|
|
61
|
+
Critical: number;
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Run regula on the specified path(s) and return parsed JSON results.
|
|
68
|
+
* @param paths - Path(s) to IaC files or directories
|
|
69
|
+
* @param options - Optional configuration
|
|
70
|
+
* @returns Parsed regula output with rule_results and summary
|
|
71
|
+
*/
|
|
72
|
+
export function runRegula(
|
|
73
|
+
paths: string | string[],
|
|
74
|
+
options?: RegulaOptions
|
|
75
|
+
): Promise<RegulaResult>;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Validate IaC files and return rule results.
|
|
79
|
+
* Alias for runRegula().
|
|
80
|
+
* @param paths - Path(s) to IaC files or directories
|
|
81
|
+
* @param options - Optional configuration
|
|
82
|
+
* @returns Object with rule_results and summary
|
|
83
|
+
*/
|
|
84
|
+
export function validate(
|
|
85
|
+
paths: string | string[],
|
|
86
|
+
options?: RegulaOptions
|
|
87
|
+
): Promise<RegulaResult>;
|
|
88
|
+
|
|
89
|
+
declare const _default: {
|
|
90
|
+
runRegula: typeof runRegula;
|
|
91
|
+
validate: typeof validate;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
export default _default;
|
package/index.js
CHANGED
|
@@ -6,19 +6,22 @@ const __filename = fileURLToPath(import.meta.url);
|
|
|
6
6
|
const __dirname = dirname(__filename);
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
* Run regula on the specified path(s)
|
|
9
|
+
* Run regula on the specified path(s) and return parsed JSON results.
|
|
10
10
|
* @param {string|string[]} paths - Path(s) to IaC files or directories
|
|
11
11
|
* @param {Object} options - Optional configuration
|
|
12
12
|
* @param {string} options.inputType - Input type: auto, tf, tf-plan, cfn, k8s, arm
|
|
13
|
-
* @param {string} options.format - Output format: json, text, table, sarif, junit, tap
|
|
14
13
|
* @param {string[]} options.include - Additional rego files to include
|
|
15
14
|
* @param {string[]} options.only - Only run specific rules
|
|
16
15
|
* @param {string[]} options.exclude - Exclude specific rules
|
|
17
|
-
* @
|
|
16
|
+
* @param {boolean} options.noBuiltIns - Disable built-in rules (use only custom rules from include)
|
|
17
|
+
* @param {boolean} options.noIgnore - Disable .gitignore filtering
|
|
18
|
+
* @param {string[]} options.varFiles - Terraform variable files to use
|
|
19
|
+
* @returns {Promise<Object>} - Parsed regula output with rule_results and summary
|
|
18
20
|
*/
|
|
19
21
|
export async function runRegula(paths, options = {}) {
|
|
20
22
|
const pathArray = Array.isArray(paths) ? paths : [paths];
|
|
21
23
|
|
|
24
|
+
// Always use JSON format for programmatic parsing
|
|
22
25
|
const args = ["run", "--format", "json"];
|
|
23
26
|
|
|
24
27
|
if (options.inputType) {
|
|
@@ -46,6 +49,21 @@ export async function runRegula(paths, options = {}) {
|
|
|
46
49
|
}
|
|
47
50
|
}
|
|
48
51
|
|
|
52
|
+
if (options.noBuiltIns) {
|
|
53
|
+
args.push("--no-built-ins");
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (options.noIgnore) {
|
|
57
|
+
args.push("--no-ignore");
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (options.varFiles) {
|
|
61
|
+
const varFiles = Array.isArray(options.varFiles) ? options.varFiles : [options.varFiles];
|
|
62
|
+
for (const varFile of varFiles) {
|
|
63
|
+
args.push("--var-file", varFile);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
49
67
|
args.push(...pathArray);
|
|
50
68
|
|
|
51
69
|
return new Promise((resolve, reject) => {
|
|
@@ -71,7 +89,8 @@ export async function runRegula(paths, options = {}) {
|
|
|
71
89
|
}
|
|
72
90
|
|
|
73
91
|
/**
|
|
74
|
-
* Validate IaC files and return rule results
|
|
92
|
+
* Validate IaC files and return rule results.
|
|
93
|
+
* Alias for runRegula().
|
|
75
94
|
* @param {string|string[]} paths - Path(s) to IaC files or directories
|
|
76
95
|
* @param {Object} options - Optional configuration
|
|
77
96
|
* @returns {Promise<Object>} - Object with rule_results and summary
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "regula-wasi",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.4",
|
|
4
4
|
"description": "Infrastructure as Code security and compliance evaluation tool (WASI build). Fork of fugue/regula with security patches.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
7
|
+
"types": "index.d.ts",
|
|
7
8
|
"bin": {
|
|
8
9
|
"regula": "cli.js"
|
|
9
10
|
},
|
|
@@ -15,6 +16,7 @@
|
|
|
15
16
|
},
|
|
16
17
|
"files": [
|
|
17
18
|
"index.js",
|
|
19
|
+
"index.d.ts",
|
|
18
20
|
"cli.js",
|
|
19
21
|
"regula.wasm",
|
|
20
22
|
"README.md",
|
package/regula.wasm
CHANGED
|
Binary file
|