cloudburn 0.1.1 → 0.2.0
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 +30 -0
- package/dist/cli.js +72 -16
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -14,6 +14,36 @@ npm install -g cloudburn
|
|
|
14
14
|
cloudburn
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
+
`cloudburn scan --format json` emits the lean canonical grouped result:
|
|
18
|
+
|
|
19
|
+
```json
|
|
20
|
+
{
|
|
21
|
+
"providers": [
|
|
22
|
+
{
|
|
23
|
+
"provider": "aws",
|
|
24
|
+
"rules": [
|
|
25
|
+
{
|
|
26
|
+
"ruleId": "CLDBRN-AWS-EBS-1",
|
|
27
|
+
"service": "ebs",
|
|
28
|
+
"source": "iac",
|
|
29
|
+
"message": "EBS volumes should use current-generation storage.",
|
|
30
|
+
"findings": [
|
|
31
|
+
{
|
|
32
|
+
"resourceId": "aws_ebs_volume.gp2_data",
|
|
33
|
+
"location": {
|
|
34
|
+
"path": "main.tf",
|
|
35
|
+
"startLine": 4,
|
|
36
|
+
"startColumn": 3
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
]
|
|
40
|
+
}
|
|
41
|
+
]
|
|
42
|
+
}
|
|
43
|
+
]
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
17
47
|
## License
|
|
18
48
|
|
|
19
49
|
Apache-2.0
|
package/dist/cli.js
CHANGED
|
@@ -59,23 +59,74 @@ var EXIT_CODE_OK = 0;
|
|
|
59
59
|
var EXIT_CODE_POLICY_VIOLATION = 1;
|
|
60
60
|
|
|
61
61
|
// src/formatters/json.ts
|
|
62
|
-
var formatJson = (
|
|
62
|
+
var formatJson = (result) => JSON.stringify(result, null, 2);
|
|
63
63
|
|
|
64
64
|
// src/formatters/markdown.ts
|
|
65
|
-
var
|
|
66
|
-
|
|
65
|
+
var formatLocation = (finding) => finding.location ? `${finding.location.path}:${finding.location.startLine}:${finding.location.startColumn}` : "";
|
|
66
|
+
var formatMarkdown = (result) => {
|
|
67
|
+
if (result.providers.length === 0) {
|
|
67
68
|
return "## CloudBurn Findings\n\nNo findings.";
|
|
68
69
|
}
|
|
69
|
-
const
|
|
70
|
+
const sections = result.providers.flatMap((providerGroup) => {
|
|
71
|
+
const providerSections = [`### ${providerGroup.provider}`];
|
|
72
|
+
for (const ruleGroup of providerGroup.rules) {
|
|
73
|
+
const hasLocations = ruleGroup.findings.some((finding) => finding.location);
|
|
74
|
+
const rows = ruleGroup.findings.map(
|
|
75
|
+
(finding) => hasLocations ? `| ${ruleGroup.source} | ${ruleGroup.service} | ${finding.resourceId} | ${ruleGroup.message} | ${formatLocation(finding)} |` : `| ${ruleGroup.source} | ${ruleGroup.service} | ${finding.resourceId} | ${ruleGroup.message} |`
|
|
76
|
+
).join("\n");
|
|
77
|
+
providerSections.push(`#### ${ruleGroup.ruleId}`);
|
|
78
|
+
providerSections.push(
|
|
79
|
+
hasLocations ? `| Source | Service | Resource | Message | Location |
|
|
80
|
+
| --- | --- | --- | --- | --- |
|
|
81
|
+
${rows}` : `| Source | Service | Resource | Message |
|
|
82
|
+
| --- | --- | --- | --- |
|
|
83
|
+
${rows}`
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
return providerSections;
|
|
87
|
+
});
|
|
70
88
|
return `## CloudBurn Findings
|
|
71
89
|
|
|
72
|
-
|
|
73
|
-
| --- | --- | --- |
|
|
74
|
-
${rows}`;
|
|
90
|
+
${sections.join("\n\n")}`;
|
|
75
91
|
};
|
|
76
92
|
|
|
93
|
+
// src/formatters/shared.ts
|
|
94
|
+
var flattenScanResult = (result) => result.providers.flatMap(
|
|
95
|
+
(providerGroup) => providerGroup.rules.flatMap(
|
|
96
|
+
(ruleGroup) => ruleGroup.findings.map((finding) => ({
|
|
97
|
+
provider: providerGroup.provider,
|
|
98
|
+
ruleId: ruleGroup.ruleId,
|
|
99
|
+
service: ruleGroup.service,
|
|
100
|
+
source: ruleGroup.source,
|
|
101
|
+
message: ruleGroup.message,
|
|
102
|
+
finding
|
|
103
|
+
}))
|
|
104
|
+
)
|
|
105
|
+
);
|
|
106
|
+
var countScanResultFindings = (result) => flattenScanResult(result).length;
|
|
107
|
+
|
|
77
108
|
// src/formatters/sarif.ts
|
|
78
|
-
var
|
|
109
|
+
var toSarifLocation = (finding) => {
|
|
110
|
+
if (!finding.location) {
|
|
111
|
+
return void 0;
|
|
112
|
+
}
|
|
113
|
+
return [
|
|
114
|
+
{
|
|
115
|
+
physicalLocation: {
|
|
116
|
+
artifactLocation: {
|
|
117
|
+
uri: finding.location.path
|
|
118
|
+
},
|
|
119
|
+
region: {
|
|
120
|
+
startLine: finding.location.startLine,
|
|
121
|
+
startColumn: finding.location.startColumn,
|
|
122
|
+
...finding.location.endLine ? { endLine: finding.location.endLine } : {},
|
|
123
|
+
...finding.location.endColumn ? { endColumn: finding.location.endColumn } : {}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
];
|
|
128
|
+
};
|
|
129
|
+
var formatSarif = (result) => JSON.stringify(
|
|
79
130
|
{
|
|
80
131
|
version: "2.1.0",
|
|
81
132
|
runs: [
|
|
@@ -85,11 +136,12 @@ var formatSarif = (findings) => JSON.stringify(
|
|
|
85
136
|
name: "cloudburn"
|
|
86
137
|
}
|
|
87
138
|
},
|
|
88
|
-
results:
|
|
89
|
-
ruleId
|
|
139
|
+
results: flattenScanResult(result).map(({ ruleId, message, finding }) => ({
|
|
140
|
+
ruleId,
|
|
90
141
|
// Severity was intentionally removed — all findings are warnings until a priority model is added.
|
|
91
142
|
level: "warning",
|
|
92
|
-
message: { text:
|
|
143
|
+
message: { text: message },
|
|
144
|
+
...finding.location ? { locations: toSarifLocation(finding) } : {}
|
|
93
145
|
}))
|
|
94
146
|
}
|
|
95
147
|
]
|
|
@@ -99,11 +151,15 @@ var formatSarif = (findings) => JSON.stringify(
|
|
|
99
151
|
);
|
|
100
152
|
|
|
101
153
|
// src/formatters/table.ts
|
|
102
|
-
var formatTable = (
|
|
103
|
-
|
|
154
|
+
var formatTable = (result) => {
|
|
155
|
+
const flattenedFindings = flattenScanResult(result);
|
|
156
|
+
if (flattenedFindings.length === 0) {
|
|
104
157
|
return "No findings.";
|
|
105
158
|
}
|
|
106
|
-
return
|
|
159
|
+
return flattenedFindings.map(({ provider, ruleId, source, service, message, finding }) => {
|
|
160
|
+
const location = finding.location ? ` ${finding.location.path}:${finding.location.startLine}:${finding.location.startColumn}` : "";
|
|
161
|
+
return `${provider} ${ruleId} ${source} ${service} ${finding.resourceId}${location} ${message}`;
|
|
162
|
+
}).join("\n");
|
|
107
163
|
};
|
|
108
164
|
|
|
109
165
|
// src/commands/scan.ts
|
|
@@ -118,10 +174,10 @@ var registerScanCommand = (program) => {
|
|
|
118
174
|
const scanner = new CloudBurnScanner();
|
|
119
175
|
const result = options.live ? await scanner.scanLive() : await scanner.scanStatic(path ?? process.cwd());
|
|
120
176
|
const format = formatters[options.format ?? "table"] ?? formatTable;
|
|
121
|
-
const output = format(result
|
|
177
|
+
const output = format(result);
|
|
122
178
|
process.stdout.write(`${output}
|
|
123
179
|
`);
|
|
124
|
-
if (options.exitCode && result
|
|
180
|
+
if (options.exitCode && countScanResultFindings(result) > 0) {
|
|
125
181
|
process.exitCode = EXIT_CODE_POLICY_VIOLATION;
|
|
126
182
|
return;
|
|
127
183
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cloudburn",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Cloudburn CLI for cloud cost optimization",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
],
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"commander": "^13.1.0",
|
|
14
|
-
"@cloudburn/sdk": "0.
|
|
14
|
+
"@cloudburn/sdk": "0.4.0"
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
|
17
17
|
"@biomejs/biome": "^2.4.6",
|