@infrascan/aws-cloudwatch-logs-scanner 0.3.1 → 0.4.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/dist/generated/client.js +13 -0
- package/dist/generated/client.mjs +3 -0
- package/dist/generated/getters.js +37 -4
- package/dist/generated/getters.mjs +27 -4
- package/dist/generated/graph.d.mts +2 -3
- package/dist/generated/graph.d.ts +2 -3
- package/dist/generated/graph.js +21 -15
- package/dist/generated/graph.mjs +10 -15
- package/dist/graph.d.mts +15 -0
- package/dist/graph.d.ts +15 -0
- package/dist/graph.js +122 -0
- package/dist/graph.mjs +97 -0
- package/dist/index.js +151 -22
- package/dist/index.mjs +138 -21
- package/package.json +10 -9
package/dist/generated/client.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
|
|
20
30
|
// src/generated/client.ts
|
|
@@ -24,7 +34,10 @@ __export(client_exports, {
|
|
|
24
34
|
});
|
|
25
35
|
module.exports = __toCommonJS(client_exports);
|
|
26
36
|
var import_client_cloudwatch_logs = require("@aws-sdk/client-cloudwatch-logs");
|
|
37
|
+
var import_debug = __toESM(require("debug"));
|
|
38
|
+
var clientDebug = (0, import_debug.default)("cloudwatch-logs:client");
|
|
27
39
|
function getClient(credentials, context, retryStrategy) {
|
|
40
|
+
clientDebug("Creating instance with context", context);
|
|
28
41
|
return new import_client_cloudwatch_logs.CloudWatchLogsClient({
|
|
29
42
|
credentials,
|
|
30
43
|
region: context.region,
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
// src/generated/client.ts
|
|
2
2
|
import { CloudWatchLogsClient } from "@aws-sdk/client-cloudwatch-logs";
|
|
3
|
+
import debug from "debug";
|
|
4
|
+
var clientDebug = debug("cloudwatch-logs:client");
|
|
3
5
|
function getClient(credentials, context, retryStrategy) {
|
|
6
|
+
clientDebug("Creating instance with context", context);
|
|
4
7
|
return new CloudWatchLogsClient({
|
|
5
8
|
credentials,
|
|
6
9
|
region: context.region,
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
|
|
20
30
|
// src/generated/getters.ts
|
|
@@ -26,9 +36,11 @@ __export(getters_exports, {
|
|
|
26
36
|
module.exports = __toCommonJS(getters_exports);
|
|
27
37
|
var import_core = require("@infrascan/core");
|
|
28
38
|
var import_client_cloudwatch_logs = require("@aws-sdk/client-cloudwatch-logs");
|
|
39
|
+
var import_debug = __toESM(require("debug"));
|
|
29
40
|
async function DescribeLogGroups(client, stateConnector, context) {
|
|
41
|
+
const getterDebug = (0, import_debug.default)("cloudwatch-logs:DescribeLogGroups");
|
|
30
42
|
const state = [];
|
|
31
|
-
|
|
43
|
+
getterDebug("Fetching state");
|
|
32
44
|
let pagingToken;
|
|
33
45
|
do {
|
|
34
46
|
const preparedParams = {};
|
|
@@ -37,11 +49,20 @@ async function DescribeLogGroups(client, stateConnector, context) {
|
|
|
37
49
|
const cmd = new import_client_cloudwatch_logs.DescribeLogGroupsCommand(preparedParams);
|
|
38
50
|
const result = await client.send(cmd);
|
|
39
51
|
state.push({
|
|
40
|
-
_metadata: {
|
|
52
|
+
_metadata: {
|
|
53
|
+
account: context.account,
|
|
54
|
+
region: context.region,
|
|
55
|
+
timestamp: Date.now()
|
|
56
|
+
},
|
|
41
57
|
_parameters: preparedParams,
|
|
42
58
|
_result: result
|
|
43
59
|
});
|
|
44
60
|
pagingToken = result.nextToken;
|
|
61
|
+
if (pagingToken != null) {
|
|
62
|
+
getterDebug("Found pagination token in response");
|
|
63
|
+
} else {
|
|
64
|
+
getterDebug("No pagination token found in response");
|
|
65
|
+
}
|
|
45
66
|
} catch (err) {
|
|
46
67
|
if (err instanceof import_client_cloudwatch_logs.CloudWatchLogsServiceException) {
|
|
47
68
|
if (err?.$retryable) {
|
|
@@ -55,6 +76,7 @@ async function DescribeLogGroups(client, stateConnector, context) {
|
|
|
55
76
|
pagingToken = void 0;
|
|
56
77
|
}
|
|
57
78
|
} while (pagingToken != null);
|
|
79
|
+
getterDebug("Recording state");
|
|
58
80
|
await stateConnector.onServiceScanCompleteCallback(
|
|
59
81
|
context.account,
|
|
60
82
|
context.region,
|
|
@@ -64,8 +86,9 @@ async function DescribeLogGroups(client, stateConnector, context) {
|
|
|
64
86
|
);
|
|
65
87
|
}
|
|
66
88
|
async function DescribeSubscriptionFilters(client, stateConnector, context) {
|
|
89
|
+
const getterDebug = (0, import_debug.default)("cloudwatch-logs:DescribeSubscriptionFilters");
|
|
67
90
|
const state = [];
|
|
68
|
-
|
|
91
|
+
getterDebug("Fetching state");
|
|
69
92
|
const resolvers = [
|
|
70
93
|
{
|
|
71
94
|
Key: "logGroupName",
|
|
@@ -87,11 +110,20 @@ async function DescribeSubscriptionFilters(client, stateConnector, context) {
|
|
|
87
110
|
const cmd = new import_client_cloudwatch_logs.DescribeSubscriptionFiltersCommand(preparedParams);
|
|
88
111
|
const result = await client.send(cmd);
|
|
89
112
|
state.push({
|
|
90
|
-
_metadata: {
|
|
113
|
+
_metadata: {
|
|
114
|
+
account: context.account,
|
|
115
|
+
region: context.region,
|
|
116
|
+
timestamp: Date.now()
|
|
117
|
+
},
|
|
91
118
|
_parameters: preparedParams,
|
|
92
119
|
_result: result
|
|
93
120
|
});
|
|
94
121
|
pagingToken = result.nextToken;
|
|
122
|
+
if (pagingToken != null) {
|
|
123
|
+
getterDebug("Found pagination token in response");
|
|
124
|
+
} else {
|
|
125
|
+
getterDebug("No pagination token found in response");
|
|
126
|
+
}
|
|
95
127
|
} catch (err) {
|
|
96
128
|
if (err instanceof import_client_cloudwatch_logs.CloudWatchLogsServiceException) {
|
|
97
129
|
if (err?.$retryable) {
|
|
@@ -106,6 +138,7 @@ async function DescribeSubscriptionFilters(client, stateConnector, context) {
|
|
|
106
138
|
}
|
|
107
139
|
} while (pagingToken != null);
|
|
108
140
|
}
|
|
141
|
+
getterDebug("Recording state");
|
|
109
142
|
await stateConnector.onServiceScanCompleteCallback(
|
|
110
143
|
context.account,
|
|
111
144
|
context.region,
|
|
@@ -5,9 +5,11 @@ import {
|
|
|
5
5
|
DescribeLogGroupsCommand,
|
|
6
6
|
DescribeSubscriptionFiltersCommand
|
|
7
7
|
} from "@aws-sdk/client-cloudwatch-logs";
|
|
8
|
+
import debug from "debug";
|
|
8
9
|
async function DescribeLogGroups(client, stateConnector, context) {
|
|
10
|
+
const getterDebug = debug("cloudwatch-logs:DescribeLogGroups");
|
|
9
11
|
const state = [];
|
|
10
|
-
|
|
12
|
+
getterDebug("Fetching state");
|
|
11
13
|
let pagingToken;
|
|
12
14
|
do {
|
|
13
15
|
const preparedParams = {};
|
|
@@ -16,11 +18,20 @@ async function DescribeLogGroups(client, stateConnector, context) {
|
|
|
16
18
|
const cmd = new DescribeLogGroupsCommand(preparedParams);
|
|
17
19
|
const result = await client.send(cmd);
|
|
18
20
|
state.push({
|
|
19
|
-
_metadata: {
|
|
21
|
+
_metadata: {
|
|
22
|
+
account: context.account,
|
|
23
|
+
region: context.region,
|
|
24
|
+
timestamp: Date.now()
|
|
25
|
+
},
|
|
20
26
|
_parameters: preparedParams,
|
|
21
27
|
_result: result
|
|
22
28
|
});
|
|
23
29
|
pagingToken = result.nextToken;
|
|
30
|
+
if (pagingToken != null) {
|
|
31
|
+
getterDebug("Found pagination token in response");
|
|
32
|
+
} else {
|
|
33
|
+
getterDebug("No pagination token found in response");
|
|
34
|
+
}
|
|
24
35
|
} catch (err) {
|
|
25
36
|
if (err instanceof CloudWatchLogsServiceException) {
|
|
26
37
|
if (err?.$retryable) {
|
|
@@ -34,6 +45,7 @@ async function DescribeLogGroups(client, stateConnector, context) {
|
|
|
34
45
|
pagingToken = void 0;
|
|
35
46
|
}
|
|
36
47
|
} while (pagingToken != null);
|
|
48
|
+
getterDebug("Recording state");
|
|
37
49
|
await stateConnector.onServiceScanCompleteCallback(
|
|
38
50
|
context.account,
|
|
39
51
|
context.region,
|
|
@@ -43,8 +55,9 @@ async function DescribeLogGroups(client, stateConnector, context) {
|
|
|
43
55
|
);
|
|
44
56
|
}
|
|
45
57
|
async function DescribeSubscriptionFilters(client, stateConnector, context) {
|
|
58
|
+
const getterDebug = debug("cloudwatch-logs:DescribeSubscriptionFilters");
|
|
46
59
|
const state = [];
|
|
47
|
-
|
|
60
|
+
getterDebug("Fetching state");
|
|
48
61
|
const resolvers = [
|
|
49
62
|
{
|
|
50
63
|
Key: "logGroupName",
|
|
@@ -66,11 +79,20 @@ async function DescribeSubscriptionFilters(client, stateConnector, context) {
|
|
|
66
79
|
const cmd = new DescribeSubscriptionFiltersCommand(preparedParams);
|
|
67
80
|
const result = await client.send(cmd);
|
|
68
81
|
state.push({
|
|
69
|
-
_metadata: {
|
|
82
|
+
_metadata: {
|
|
83
|
+
account: context.account,
|
|
84
|
+
region: context.region,
|
|
85
|
+
timestamp: Date.now()
|
|
86
|
+
},
|
|
70
87
|
_parameters: preparedParams,
|
|
71
88
|
_result: result
|
|
72
89
|
});
|
|
73
90
|
pagingToken = result.nextToken;
|
|
91
|
+
if (pagingToken != null) {
|
|
92
|
+
getterDebug("Found pagination token in response");
|
|
93
|
+
} else {
|
|
94
|
+
getterDebug("No pagination token found in response");
|
|
95
|
+
}
|
|
74
96
|
} catch (err) {
|
|
75
97
|
if (err instanceof CloudWatchLogsServiceException) {
|
|
76
98
|
if (err?.$retryable) {
|
|
@@ -85,6 +107,7 @@ async function DescribeSubscriptionFilters(client, stateConnector, context) {
|
|
|
85
107
|
}
|
|
86
108
|
} while (pagingToken != null);
|
|
87
109
|
}
|
|
110
|
+
getterDebug("Recording state");
|
|
88
111
|
await stateConnector.onServiceScanCompleteCallback(
|
|
89
112
|
context.account,
|
|
90
113
|
context.region,
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { Connector,
|
|
1
|
+
import { Connector, SelectedEdge } from '@infrascan/shared-types';
|
|
2
2
|
|
|
3
|
-
declare function getNodes(stateConnector: Connector, context: AwsContext): Promise<SelectedNode[]>;
|
|
4
3
|
declare function getEdges(stateConnector: Connector): Promise<SelectedEdge[]>;
|
|
5
4
|
|
|
6
|
-
export { getEdges
|
|
5
|
+
export { getEdges };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { Connector,
|
|
1
|
+
import { Connector, SelectedEdge } from '@infrascan/shared-types';
|
|
2
2
|
|
|
3
|
-
declare function getNodes(stateConnector: Connector, context: AwsContext): Promise<SelectedNode[]>;
|
|
4
3
|
declare function getEdges(stateConnector: Connector): Promise<SelectedEdge[]>;
|
|
5
4
|
|
|
6
|
-
export { getEdges
|
|
5
|
+
export { getEdges };
|
package/dist/generated/graph.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,29 +17,31 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
|
|
20
30
|
// src/generated/graph.ts
|
|
21
31
|
var graph_exports = {};
|
|
22
32
|
__export(graph_exports, {
|
|
23
|
-
getEdges: () => getEdges
|
|
24
|
-
getNodes: () => getNodes
|
|
33
|
+
getEdges: () => getEdges
|
|
25
34
|
});
|
|
26
35
|
module.exports = __toCommonJS(graph_exports);
|
|
27
36
|
var import_core = require("@infrascan/core");
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const DescribeSubscriptionFiltersNodes = await (0, import_core.evaluateSelector)(
|
|
31
|
-
context.account,
|
|
32
|
-
context.region,
|
|
33
|
-
"CloudWatchLogs|DescribeSubscriptionFilters|[]._result.subscriptionFilters[].{id:logGroupName,name:logGroupName}",
|
|
34
|
-
stateConnector
|
|
35
|
-
);
|
|
36
|
-
state.push(...DescribeSubscriptionFiltersNodes);
|
|
37
|
-
return state.map((node) => (0, import_core.formatNode)(node, "CloudWatchLogs", context, true));
|
|
38
|
-
}
|
|
37
|
+
var import_debug = __toESM(require("debug"));
|
|
38
|
+
var edgesDebug = (0, import_debug.default)("cloudwatch-logs:edges");
|
|
39
39
|
async function getEdges(stateConnector) {
|
|
40
|
+
edgesDebug("Fetching edges");
|
|
40
41
|
const edges = [];
|
|
42
|
+
edgesDebug(
|
|
43
|
+
"Evaluating CloudWatchLogs|DescribeSubscriptionFilters|[]._result.subscriptionFilters[]"
|
|
44
|
+
);
|
|
41
45
|
const DescribeSubscriptionFiltersState1 = await (0, import_core.evaluateSelectorGlobally)(
|
|
42
46
|
"CloudWatchLogs|DescribeSubscriptionFilters|[]._result.subscriptionFilters[]",
|
|
43
47
|
stateConnector
|
|
@@ -53,11 +57,13 @@ async function getEdges(stateConnector) {
|
|
|
53
57
|
}
|
|
54
58
|
return (0, import_core.formatEdge)(source, target);
|
|
55
59
|
});
|
|
60
|
+
edgesDebug(
|
|
61
|
+
`Evaluated CloudWatchLogs|DescribeSubscriptionFilters|[]._result.subscriptionFilters[]: ${DescribeSubscriptionFiltersEdges1.length} Edges found`
|
|
62
|
+
);
|
|
56
63
|
edges.push(...DescribeSubscriptionFiltersEdges1);
|
|
57
64
|
return edges;
|
|
58
65
|
}
|
|
59
66
|
// Annotate the CommonJS export names for ESM import in node:
|
|
60
67
|
0 && (module.exports = {
|
|
61
|
-
getEdges
|
|
62
|
-
getNodes
|
|
68
|
+
getEdges
|
|
63
69
|
});
|
package/dist/generated/graph.mjs
CHANGED
|
@@ -1,24 +1,17 @@
|
|
|
1
1
|
// src/generated/graph.ts
|
|
2
2
|
import {
|
|
3
|
-
evaluateSelector,
|
|
4
|
-
formatNode,
|
|
5
3
|
evaluateSelectorGlobally,
|
|
6
4
|
filterState,
|
|
7
5
|
formatEdge
|
|
8
6
|
} from "@infrascan/core";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const DescribeSubscriptionFiltersNodes = await evaluateSelector(
|
|
12
|
-
context.account,
|
|
13
|
-
context.region,
|
|
14
|
-
"CloudWatchLogs|DescribeSubscriptionFilters|[]._result.subscriptionFilters[].{id:logGroupName,name:logGroupName}",
|
|
15
|
-
stateConnector
|
|
16
|
-
);
|
|
17
|
-
state.push(...DescribeSubscriptionFiltersNodes);
|
|
18
|
-
return state.map((node) => formatNode(node, "CloudWatchLogs", context, true));
|
|
19
|
-
}
|
|
7
|
+
import debug from "debug";
|
|
8
|
+
var edgesDebug = debug("cloudwatch-logs:edges");
|
|
20
9
|
async function getEdges(stateConnector) {
|
|
10
|
+
edgesDebug("Fetching edges");
|
|
21
11
|
const edges = [];
|
|
12
|
+
edgesDebug(
|
|
13
|
+
"Evaluating CloudWatchLogs|DescribeSubscriptionFilters|[]._result.subscriptionFilters[]"
|
|
14
|
+
);
|
|
22
15
|
const DescribeSubscriptionFiltersState1 = await evaluateSelectorGlobally(
|
|
23
16
|
"CloudWatchLogs|DescribeSubscriptionFilters|[]._result.subscriptionFilters[]",
|
|
24
17
|
stateConnector
|
|
@@ -34,10 +27,12 @@ async function getEdges(stateConnector) {
|
|
|
34
27
|
}
|
|
35
28
|
return formatEdge(source, target);
|
|
36
29
|
});
|
|
30
|
+
edgesDebug(
|
|
31
|
+
`Evaluated CloudWatchLogs|DescribeSubscriptionFilters|[]._result.subscriptionFilters[]: ${DescribeSubscriptionFiltersEdges1.length} Edges found`
|
|
32
|
+
);
|
|
37
33
|
edges.push(...DescribeSubscriptionFiltersEdges1);
|
|
38
34
|
return edges;
|
|
39
35
|
}
|
|
40
36
|
export {
|
|
41
|
-
getEdges
|
|
42
|
-
getNodes
|
|
37
|
+
getEdges
|
|
43
38
|
};
|
package/dist/graph.d.mts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { DescribeLogGroupsCommandInput, DescribeLogGroupsCommandOutput, LogGroup } from '@aws-sdk/client-cloudwatch-logs';
|
|
2
|
+
import { BaseState, QualifiedMeasure, TimeUnit, SizeUnit, TranslatedEntity, State, WithCallContext } from '@infrascan/shared-types';
|
|
3
|
+
|
|
4
|
+
type CloudwatchLogGroup = BaseState<DescribeLogGroupsCommandInput> & {
|
|
5
|
+
logGroup: {
|
|
6
|
+
dataProtectionStatus?: string;
|
|
7
|
+
accessClass?: string;
|
|
8
|
+
metricFilterCount?: number;
|
|
9
|
+
retentionPeriod?: QualifiedMeasure<TimeUnit>;
|
|
10
|
+
size?: QualifiedMeasure<SizeUnit>;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
declare const CloudwatchLogGroupEntity: TranslatedEntity<CloudwatchLogGroup, State<DescribeLogGroupsCommandOutput, DescribeLogGroupsCommandInput>, WithCallContext<LogGroup, DescribeLogGroupsCommandInput>>;
|
|
14
|
+
|
|
15
|
+
export { type CloudwatchLogGroup, CloudwatchLogGroupEntity };
|
package/dist/graph.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { DescribeLogGroupsCommandInput, DescribeLogGroupsCommandOutput, LogGroup } from '@aws-sdk/client-cloudwatch-logs';
|
|
2
|
+
import { BaseState, QualifiedMeasure, TimeUnit, SizeUnit, TranslatedEntity, State, WithCallContext } from '@infrascan/shared-types';
|
|
3
|
+
|
|
4
|
+
type CloudwatchLogGroup = BaseState<DescribeLogGroupsCommandInput> & {
|
|
5
|
+
logGroup: {
|
|
6
|
+
dataProtectionStatus?: string;
|
|
7
|
+
accessClass?: string;
|
|
8
|
+
metricFilterCount?: number;
|
|
9
|
+
retentionPeriod?: QualifiedMeasure<TimeUnit>;
|
|
10
|
+
size?: QualifiedMeasure<SizeUnit>;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
declare const CloudwatchLogGroupEntity: TranslatedEntity<CloudwatchLogGroup, State<DescribeLogGroupsCommandOutput, DescribeLogGroupsCommandInput>, WithCallContext<LogGroup, DescribeLogGroupsCommandInput>>;
|
|
14
|
+
|
|
15
|
+
export { type CloudwatchLogGroup, CloudwatchLogGroupEntity };
|
package/dist/graph.js
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/graph.ts
|
|
21
|
+
var graph_exports = {};
|
|
22
|
+
__export(graph_exports, {
|
|
23
|
+
CloudwatchLogGroupEntity: () => CloudwatchLogGroupEntity
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(graph_exports);
|
|
26
|
+
var import_core = require("@infrascan/core");
|
|
27
|
+
var CloudwatchLogGroupEntity = {
|
|
28
|
+
version: "0.1.0",
|
|
29
|
+
debugLabel: "cloudwatch-logs",
|
|
30
|
+
provider: "aws",
|
|
31
|
+
command: "DescribeLogGroups",
|
|
32
|
+
category: "cloudwatch",
|
|
33
|
+
subcategory: "logs",
|
|
34
|
+
nodeType: "cloudwatch-logs",
|
|
35
|
+
selector: "CloudWatchLogs|DescribeLogGroups|[]",
|
|
36
|
+
getState(state, context) {
|
|
37
|
+
return (0, import_core.evaluateSelector)(
|
|
38
|
+
context.account,
|
|
39
|
+
context.region,
|
|
40
|
+
CloudwatchLogGroupEntity.selector,
|
|
41
|
+
state
|
|
42
|
+
);
|
|
43
|
+
},
|
|
44
|
+
translate(val) {
|
|
45
|
+
return (val._result.logGroups ?? []).map(
|
|
46
|
+
(group) => Object.assign(group, {
|
|
47
|
+
$metadata: val._metadata,
|
|
48
|
+
$parameters: val._parameters
|
|
49
|
+
})
|
|
50
|
+
);
|
|
51
|
+
},
|
|
52
|
+
components: {
|
|
53
|
+
$metadata(val) {
|
|
54
|
+
return {
|
|
55
|
+
version: CloudwatchLogGroupEntity.version,
|
|
56
|
+
timestamp: val.$metadata.timestamp
|
|
57
|
+
};
|
|
58
|
+
},
|
|
59
|
+
$graph(val) {
|
|
60
|
+
return {
|
|
61
|
+
id: val.logGroupArn ?? val.arn,
|
|
62
|
+
label: val.logGroupName,
|
|
63
|
+
nodeType: CloudwatchLogGroupEntity.nodeType
|
|
64
|
+
};
|
|
65
|
+
},
|
|
66
|
+
$source(val) {
|
|
67
|
+
return {
|
|
68
|
+
command: CloudwatchLogGroupEntity.command,
|
|
69
|
+
parameters: val.$parameters
|
|
70
|
+
};
|
|
71
|
+
},
|
|
72
|
+
tenant(val) {
|
|
73
|
+
return {
|
|
74
|
+
tenantId: val.$metadata.account,
|
|
75
|
+
provider: CloudwatchLogGroupEntity.provider,
|
|
76
|
+
partition: val.$metadata.partition
|
|
77
|
+
};
|
|
78
|
+
},
|
|
79
|
+
location(val) {
|
|
80
|
+
return {
|
|
81
|
+
code: val.$metadata.region
|
|
82
|
+
};
|
|
83
|
+
},
|
|
84
|
+
resource(val) {
|
|
85
|
+
return {
|
|
86
|
+
id: val.logGroupArn,
|
|
87
|
+
name: val.logGroupName,
|
|
88
|
+
category: CloudwatchLogGroupEntity.category,
|
|
89
|
+
subcategory: CloudwatchLogGroupEntity.subcategory
|
|
90
|
+
};
|
|
91
|
+
},
|
|
92
|
+
audit(val) {
|
|
93
|
+
return {
|
|
94
|
+
createdAt: val.creationTime != null ? new Date(val.creationTime) : void 0
|
|
95
|
+
};
|
|
96
|
+
},
|
|
97
|
+
encryption(val) {
|
|
98
|
+
return {
|
|
99
|
+
keyId: val.kmsKeyId
|
|
100
|
+
};
|
|
101
|
+
},
|
|
102
|
+
logGroup(val) {
|
|
103
|
+
return {
|
|
104
|
+
accessClass: val.logGroupClass != null ? (0, import_core.toLowerCase)(val.logGroupClass) : void 0,
|
|
105
|
+
dataProtectionStatus: val.dataProtectionStatus != null ? (0, import_core.toLowerCase)(val.dataProtectionStatus) : void 0,
|
|
106
|
+
retentionPeriod: val.retentionInDays != null ? {
|
|
107
|
+
unit: import_core.Time.Days,
|
|
108
|
+
value: val.retentionInDays
|
|
109
|
+
} : void 0,
|
|
110
|
+
size: val.storedBytes != null ? {
|
|
111
|
+
unit: import_core.Size.Bytes,
|
|
112
|
+
value: val.storedBytes
|
|
113
|
+
} : void 0,
|
|
114
|
+
metricFilterCount: val.metricFilterCount
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
120
|
+
0 && (module.exports = {
|
|
121
|
+
CloudwatchLogGroupEntity
|
|
122
|
+
});
|
package/dist/graph.mjs
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
// src/graph.ts
|
|
2
|
+
import { evaluateSelector, toLowerCase, Time, Size } from "@infrascan/core";
|
|
3
|
+
var CloudwatchLogGroupEntity = {
|
|
4
|
+
version: "0.1.0",
|
|
5
|
+
debugLabel: "cloudwatch-logs",
|
|
6
|
+
provider: "aws",
|
|
7
|
+
command: "DescribeLogGroups",
|
|
8
|
+
category: "cloudwatch",
|
|
9
|
+
subcategory: "logs",
|
|
10
|
+
nodeType: "cloudwatch-logs",
|
|
11
|
+
selector: "CloudWatchLogs|DescribeLogGroups|[]",
|
|
12
|
+
getState(state, context) {
|
|
13
|
+
return evaluateSelector(
|
|
14
|
+
context.account,
|
|
15
|
+
context.region,
|
|
16
|
+
CloudwatchLogGroupEntity.selector,
|
|
17
|
+
state
|
|
18
|
+
);
|
|
19
|
+
},
|
|
20
|
+
translate(val) {
|
|
21
|
+
return (val._result.logGroups ?? []).map(
|
|
22
|
+
(group) => Object.assign(group, {
|
|
23
|
+
$metadata: val._metadata,
|
|
24
|
+
$parameters: val._parameters
|
|
25
|
+
})
|
|
26
|
+
);
|
|
27
|
+
},
|
|
28
|
+
components: {
|
|
29
|
+
$metadata(val) {
|
|
30
|
+
return {
|
|
31
|
+
version: CloudwatchLogGroupEntity.version,
|
|
32
|
+
timestamp: val.$metadata.timestamp
|
|
33
|
+
};
|
|
34
|
+
},
|
|
35
|
+
$graph(val) {
|
|
36
|
+
return {
|
|
37
|
+
id: val.logGroupArn ?? val.arn,
|
|
38
|
+
label: val.logGroupName,
|
|
39
|
+
nodeType: CloudwatchLogGroupEntity.nodeType
|
|
40
|
+
};
|
|
41
|
+
},
|
|
42
|
+
$source(val) {
|
|
43
|
+
return {
|
|
44
|
+
command: CloudwatchLogGroupEntity.command,
|
|
45
|
+
parameters: val.$parameters
|
|
46
|
+
};
|
|
47
|
+
},
|
|
48
|
+
tenant(val) {
|
|
49
|
+
return {
|
|
50
|
+
tenantId: val.$metadata.account,
|
|
51
|
+
provider: CloudwatchLogGroupEntity.provider,
|
|
52
|
+
partition: val.$metadata.partition
|
|
53
|
+
};
|
|
54
|
+
},
|
|
55
|
+
location(val) {
|
|
56
|
+
return {
|
|
57
|
+
code: val.$metadata.region
|
|
58
|
+
};
|
|
59
|
+
},
|
|
60
|
+
resource(val) {
|
|
61
|
+
return {
|
|
62
|
+
id: val.logGroupArn,
|
|
63
|
+
name: val.logGroupName,
|
|
64
|
+
category: CloudwatchLogGroupEntity.category,
|
|
65
|
+
subcategory: CloudwatchLogGroupEntity.subcategory
|
|
66
|
+
};
|
|
67
|
+
},
|
|
68
|
+
audit(val) {
|
|
69
|
+
return {
|
|
70
|
+
createdAt: val.creationTime != null ? new Date(val.creationTime) : void 0
|
|
71
|
+
};
|
|
72
|
+
},
|
|
73
|
+
encryption(val) {
|
|
74
|
+
return {
|
|
75
|
+
keyId: val.kmsKeyId
|
|
76
|
+
};
|
|
77
|
+
},
|
|
78
|
+
logGroup(val) {
|
|
79
|
+
return {
|
|
80
|
+
accessClass: val.logGroupClass != null ? toLowerCase(val.logGroupClass) : void 0,
|
|
81
|
+
dataProtectionStatus: val.dataProtectionStatus != null ? toLowerCase(val.dataProtectionStatus) : void 0,
|
|
82
|
+
retentionPeriod: val.retentionInDays != null ? {
|
|
83
|
+
unit: Time.Days,
|
|
84
|
+
value: val.retentionInDays
|
|
85
|
+
} : void 0,
|
|
86
|
+
size: val.storedBytes != null ? {
|
|
87
|
+
unit: Size.Bytes,
|
|
88
|
+
value: val.storedBytes
|
|
89
|
+
} : void 0,
|
|
90
|
+
metricFilterCount: val.metricFilterCount
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
export {
|
|
96
|
+
CloudwatchLogGroupEntity
|
|
97
|
+
};
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,18 +17,29 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
|
|
20
30
|
// src/index.ts
|
|
21
|
-
var
|
|
22
|
-
__export(
|
|
23
|
-
default: () =>
|
|
31
|
+
var index_exports = {};
|
|
32
|
+
__export(index_exports, {
|
|
33
|
+
default: () => index_default
|
|
24
34
|
});
|
|
25
|
-
module.exports = __toCommonJS(
|
|
35
|
+
module.exports = __toCommonJS(index_exports);
|
|
26
36
|
|
|
27
37
|
// src/generated/client.ts
|
|
28
38
|
var import_client_cloudwatch_logs = require("@aws-sdk/client-cloudwatch-logs");
|
|
39
|
+
var import_debug = __toESM(require("debug"));
|
|
40
|
+
var clientDebug = (0, import_debug.default)("cloudwatch-logs:client");
|
|
29
41
|
function getClient(credentials, context, retryStrategy) {
|
|
42
|
+
clientDebug("Creating instance with context", context);
|
|
30
43
|
return new import_client_cloudwatch_logs.CloudWatchLogsClient({
|
|
31
44
|
credentials,
|
|
32
45
|
region: context.region,
|
|
@@ -37,9 +50,11 @@ function getClient(credentials, context, retryStrategy) {
|
|
|
37
50
|
// src/generated/getters.ts
|
|
38
51
|
var import_core = require("@infrascan/core");
|
|
39
52
|
var import_client_cloudwatch_logs2 = require("@aws-sdk/client-cloudwatch-logs");
|
|
53
|
+
var import_debug2 = __toESM(require("debug"));
|
|
40
54
|
async function DescribeLogGroups(client, stateConnector, context) {
|
|
55
|
+
const getterDebug = (0, import_debug2.default)("cloudwatch-logs:DescribeLogGroups");
|
|
41
56
|
const state = [];
|
|
42
|
-
|
|
57
|
+
getterDebug("Fetching state");
|
|
43
58
|
let pagingToken;
|
|
44
59
|
do {
|
|
45
60
|
const preparedParams = {};
|
|
@@ -48,11 +63,20 @@ async function DescribeLogGroups(client, stateConnector, context) {
|
|
|
48
63
|
const cmd = new import_client_cloudwatch_logs2.DescribeLogGroupsCommand(preparedParams);
|
|
49
64
|
const result = await client.send(cmd);
|
|
50
65
|
state.push({
|
|
51
|
-
_metadata: {
|
|
66
|
+
_metadata: {
|
|
67
|
+
account: context.account,
|
|
68
|
+
region: context.region,
|
|
69
|
+
timestamp: Date.now()
|
|
70
|
+
},
|
|
52
71
|
_parameters: preparedParams,
|
|
53
72
|
_result: result
|
|
54
73
|
});
|
|
55
74
|
pagingToken = result.nextToken;
|
|
75
|
+
if (pagingToken != null) {
|
|
76
|
+
getterDebug("Found pagination token in response");
|
|
77
|
+
} else {
|
|
78
|
+
getterDebug("No pagination token found in response");
|
|
79
|
+
}
|
|
56
80
|
} catch (err) {
|
|
57
81
|
if (err instanceof import_client_cloudwatch_logs2.CloudWatchLogsServiceException) {
|
|
58
82
|
if (err?.$retryable) {
|
|
@@ -66,6 +90,7 @@ async function DescribeLogGroups(client, stateConnector, context) {
|
|
|
66
90
|
pagingToken = void 0;
|
|
67
91
|
}
|
|
68
92
|
} while (pagingToken != null);
|
|
93
|
+
getterDebug("Recording state");
|
|
69
94
|
await stateConnector.onServiceScanCompleteCallback(
|
|
70
95
|
context.account,
|
|
71
96
|
context.region,
|
|
@@ -75,8 +100,9 @@ async function DescribeLogGroups(client, stateConnector, context) {
|
|
|
75
100
|
);
|
|
76
101
|
}
|
|
77
102
|
async function DescribeSubscriptionFilters(client, stateConnector, context) {
|
|
103
|
+
const getterDebug = (0, import_debug2.default)("cloudwatch-logs:DescribeSubscriptionFilters");
|
|
78
104
|
const state = [];
|
|
79
|
-
|
|
105
|
+
getterDebug("Fetching state");
|
|
80
106
|
const resolvers = [
|
|
81
107
|
{
|
|
82
108
|
Key: "logGroupName",
|
|
@@ -98,11 +124,20 @@ async function DescribeSubscriptionFilters(client, stateConnector, context) {
|
|
|
98
124
|
const cmd = new import_client_cloudwatch_logs2.DescribeSubscriptionFiltersCommand(preparedParams);
|
|
99
125
|
const result = await client.send(cmd);
|
|
100
126
|
state.push({
|
|
101
|
-
_metadata: {
|
|
127
|
+
_metadata: {
|
|
128
|
+
account: context.account,
|
|
129
|
+
region: context.region,
|
|
130
|
+
timestamp: Date.now()
|
|
131
|
+
},
|
|
102
132
|
_parameters: preparedParams,
|
|
103
133
|
_result: result
|
|
104
134
|
});
|
|
105
135
|
pagingToken = result.nextToken;
|
|
136
|
+
if (pagingToken != null) {
|
|
137
|
+
getterDebug("Found pagination token in response");
|
|
138
|
+
} else {
|
|
139
|
+
getterDebug("No pagination token found in response");
|
|
140
|
+
}
|
|
106
141
|
} catch (err) {
|
|
107
142
|
if (err instanceof import_client_cloudwatch_logs2.CloudWatchLogsServiceException) {
|
|
108
143
|
if (err?.$retryable) {
|
|
@@ -117,6 +152,7 @@ async function DescribeSubscriptionFilters(client, stateConnector, context) {
|
|
|
117
152
|
}
|
|
118
153
|
} while (pagingToken != null);
|
|
119
154
|
}
|
|
155
|
+
getterDebug("Recording state");
|
|
120
156
|
await stateConnector.onServiceScanCompleteCallback(
|
|
121
157
|
context.account,
|
|
122
158
|
context.region,
|
|
@@ -128,19 +164,14 @@ async function DescribeSubscriptionFilters(client, stateConnector, context) {
|
|
|
128
164
|
|
|
129
165
|
// src/generated/graph.ts
|
|
130
166
|
var import_core2 = require("@infrascan/core");
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
const DescribeSubscriptionFiltersNodes = await (0, import_core2.evaluateSelector)(
|
|
134
|
-
context.account,
|
|
135
|
-
context.region,
|
|
136
|
-
"CloudWatchLogs|DescribeSubscriptionFilters|[]._result.subscriptionFilters[].{id:logGroupName,name:logGroupName}",
|
|
137
|
-
stateConnector
|
|
138
|
-
);
|
|
139
|
-
state.push(...DescribeSubscriptionFiltersNodes);
|
|
140
|
-
return state.map((node) => (0, import_core2.formatNode)(node, "CloudWatchLogs", context, true));
|
|
141
|
-
}
|
|
167
|
+
var import_debug3 = __toESM(require("debug"));
|
|
168
|
+
var edgesDebug = (0, import_debug3.default)("cloudwatch-logs:edges");
|
|
142
169
|
async function getEdges(stateConnector) {
|
|
170
|
+
edgesDebug("Fetching edges");
|
|
143
171
|
const edges = [];
|
|
172
|
+
edgesDebug(
|
|
173
|
+
"Evaluating CloudWatchLogs|DescribeSubscriptionFilters|[]._result.subscriptionFilters[]"
|
|
174
|
+
);
|
|
144
175
|
const DescribeSubscriptionFiltersState1 = await (0, import_core2.evaluateSelectorGlobally)(
|
|
145
176
|
"CloudWatchLogs|DescribeSubscriptionFilters|[]._result.subscriptionFilters[]",
|
|
146
177
|
stateConnector
|
|
@@ -156,10 +187,108 @@ async function getEdges(stateConnector) {
|
|
|
156
187
|
}
|
|
157
188
|
return (0, import_core2.formatEdge)(source, target);
|
|
158
189
|
});
|
|
190
|
+
edgesDebug(
|
|
191
|
+
`Evaluated CloudWatchLogs|DescribeSubscriptionFilters|[]._result.subscriptionFilters[]: ${DescribeSubscriptionFiltersEdges1.length} Edges found`
|
|
192
|
+
);
|
|
159
193
|
edges.push(...DescribeSubscriptionFiltersEdges1);
|
|
160
194
|
return edges;
|
|
161
195
|
}
|
|
162
196
|
|
|
197
|
+
// src/graph.ts
|
|
198
|
+
var import_core3 = require("@infrascan/core");
|
|
199
|
+
var CloudwatchLogGroupEntity = {
|
|
200
|
+
version: "0.1.0",
|
|
201
|
+
debugLabel: "cloudwatch-logs",
|
|
202
|
+
provider: "aws",
|
|
203
|
+
command: "DescribeLogGroups",
|
|
204
|
+
category: "cloudwatch",
|
|
205
|
+
subcategory: "logs",
|
|
206
|
+
nodeType: "cloudwatch-logs",
|
|
207
|
+
selector: "CloudWatchLogs|DescribeLogGroups|[]",
|
|
208
|
+
getState(state, context) {
|
|
209
|
+
return (0, import_core3.evaluateSelector)(
|
|
210
|
+
context.account,
|
|
211
|
+
context.region,
|
|
212
|
+
CloudwatchLogGroupEntity.selector,
|
|
213
|
+
state
|
|
214
|
+
);
|
|
215
|
+
},
|
|
216
|
+
translate(val) {
|
|
217
|
+
return (val._result.logGroups ?? []).map(
|
|
218
|
+
(group) => Object.assign(group, {
|
|
219
|
+
$metadata: val._metadata,
|
|
220
|
+
$parameters: val._parameters
|
|
221
|
+
})
|
|
222
|
+
);
|
|
223
|
+
},
|
|
224
|
+
components: {
|
|
225
|
+
$metadata(val) {
|
|
226
|
+
return {
|
|
227
|
+
version: CloudwatchLogGroupEntity.version,
|
|
228
|
+
timestamp: val.$metadata.timestamp
|
|
229
|
+
};
|
|
230
|
+
},
|
|
231
|
+
$graph(val) {
|
|
232
|
+
return {
|
|
233
|
+
id: val.logGroupArn ?? val.arn,
|
|
234
|
+
label: val.logGroupName,
|
|
235
|
+
nodeType: CloudwatchLogGroupEntity.nodeType
|
|
236
|
+
};
|
|
237
|
+
},
|
|
238
|
+
$source(val) {
|
|
239
|
+
return {
|
|
240
|
+
command: CloudwatchLogGroupEntity.command,
|
|
241
|
+
parameters: val.$parameters
|
|
242
|
+
};
|
|
243
|
+
},
|
|
244
|
+
tenant(val) {
|
|
245
|
+
return {
|
|
246
|
+
tenantId: val.$metadata.account,
|
|
247
|
+
provider: CloudwatchLogGroupEntity.provider,
|
|
248
|
+
partition: val.$metadata.partition
|
|
249
|
+
};
|
|
250
|
+
},
|
|
251
|
+
location(val) {
|
|
252
|
+
return {
|
|
253
|
+
code: val.$metadata.region
|
|
254
|
+
};
|
|
255
|
+
},
|
|
256
|
+
resource(val) {
|
|
257
|
+
return {
|
|
258
|
+
id: val.logGroupArn,
|
|
259
|
+
name: val.logGroupName,
|
|
260
|
+
category: CloudwatchLogGroupEntity.category,
|
|
261
|
+
subcategory: CloudwatchLogGroupEntity.subcategory
|
|
262
|
+
};
|
|
263
|
+
},
|
|
264
|
+
audit(val) {
|
|
265
|
+
return {
|
|
266
|
+
createdAt: val.creationTime != null ? new Date(val.creationTime) : void 0
|
|
267
|
+
};
|
|
268
|
+
},
|
|
269
|
+
encryption(val) {
|
|
270
|
+
return {
|
|
271
|
+
keyId: val.kmsKeyId
|
|
272
|
+
};
|
|
273
|
+
},
|
|
274
|
+
logGroup(val) {
|
|
275
|
+
return {
|
|
276
|
+
accessClass: val.logGroupClass != null ? (0, import_core3.toLowerCase)(val.logGroupClass) : void 0,
|
|
277
|
+
dataProtectionStatus: val.dataProtectionStatus != null ? (0, import_core3.toLowerCase)(val.dataProtectionStatus) : void 0,
|
|
278
|
+
retentionPeriod: val.retentionInDays != null ? {
|
|
279
|
+
unit: import_core3.Time.Days,
|
|
280
|
+
value: val.retentionInDays
|
|
281
|
+
} : void 0,
|
|
282
|
+
size: val.storedBytes != null ? {
|
|
283
|
+
unit: import_core3.Size.Bytes,
|
|
284
|
+
value: val.storedBytes
|
|
285
|
+
} : void 0,
|
|
286
|
+
metricFilterCount: val.metricFilterCount
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
};
|
|
291
|
+
|
|
163
292
|
// src/index.ts
|
|
164
293
|
var CloudWatchLogsScanner = {
|
|
165
294
|
provider: "aws",
|
|
@@ -169,7 +298,7 @@ var CloudWatchLogsScanner = {
|
|
|
169
298
|
getClient,
|
|
170
299
|
callPerRegion: true,
|
|
171
300
|
getters: [DescribeLogGroups, DescribeSubscriptionFilters],
|
|
172
|
-
|
|
173
|
-
|
|
301
|
+
getEdges,
|
|
302
|
+
entities: [CloudwatchLogGroupEntity]
|
|
174
303
|
};
|
|
175
|
-
var
|
|
304
|
+
var index_default = CloudWatchLogsScanner;
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
// src/generated/client.ts
|
|
2
2
|
import { CloudWatchLogsClient } from "@aws-sdk/client-cloudwatch-logs";
|
|
3
|
+
import debug from "debug";
|
|
4
|
+
var clientDebug = debug("cloudwatch-logs:client");
|
|
3
5
|
function getClient(credentials, context, retryStrategy) {
|
|
6
|
+
clientDebug("Creating instance with context", context);
|
|
4
7
|
return new CloudWatchLogsClient({
|
|
5
8
|
credentials,
|
|
6
9
|
region: context.region,
|
|
@@ -15,9 +18,11 @@ import {
|
|
|
15
18
|
DescribeLogGroupsCommand,
|
|
16
19
|
DescribeSubscriptionFiltersCommand
|
|
17
20
|
} from "@aws-sdk/client-cloudwatch-logs";
|
|
21
|
+
import debug2 from "debug";
|
|
18
22
|
async function DescribeLogGroups(client, stateConnector, context) {
|
|
23
|
+
const getterDebug = debug2("cloudwatch-logs:DescribeLogGroups");
|
|
19
24
|
const state = [];
|
|
20
|
-
|
|
25
|
+
getterDebug("Fetching state");
|
|
21
26
|
let pagingToken;
|
|
22
27
|
do {
|
|
23
28
|
const preparedParams = {};
|
|
@@ -26,11 +31,20 @@ async function DescribeLogGroups(client, stateConnector, context) {
|
|
|
26
31
|
const cmd = new DescribeLogGroupsCommand(preparedParams);
|
|
27
32
|
const result = await client.send(cmd);
|
|
28
33
|
state.push({
|
|
29
|
-
_metadata: {
|
|
34
|
+
_metadata: {
|
|
35
|
+
account: context.account,
|
|
36
|
+
region: context.region,
|
|
37
|
+
timestamp: Date.now()
|
|
38
|
+
},
|
|
30
39
|
_parameters: preparedParams,
|
|
31
40
|
_result: result
|
|
32
41
|
});
|
|
33
42
|
pagingToken = result.nextToken;
|
|
43
|
+
if (pagingToken != null) {
|
|
44
|
+
getterDebug("Found pagination token in response");
|
|
45
|
+
} else {
|
|
46
|
+
getterDebug("No pagination token found in response");
|
|
47
|
+
}
|
|
34
48
|
} catch (err) {
|
|
35
49
|
if (err instanceof CloudWatchLogsServiceException) {
|
|
36
50
|
if (err?.$retryable) {
|
|
@@ -44,6 +58,7 @@ async function DescribeLogGroups(client, stateConnector, context) {
|
|
|
44
58
|
pagingToken = void 0;
|
|
45
59
|
}
|
|
46
60
|
} while (pagingToken != null);
|
|
61
|
+
getterDebug("Recording state");
|
|
47
62
|
await stateConnector.onServiceScanCompleteCallback(
|
|
48
63
|
context.account,
|
|
49
64
|
context.region,
|
|
@@ -53,8 +68,9 @@ async function DescribeLogGroups(client, stateConnector, context) {
|
|
|
53
68
|
);
|
|
54
69
|
}
|
|
55
70
|
async function DescribeSubscriptionFilters(client, stateConnector, context) {
|
|
71
|
+
const getterDebug = debug2("cloudwatch-logs:DescribeSubscriptionFilters");
|
|
56
72
|
const state = [];
|
|
57
|
-
|
|
73
|
+
getterDebug("Fetching state");
|
|
58
74
|
const resolvers = [
|
|
59
75
|
{
|
|
60
76
|
Key: "logGroupName",
|
|
@@ -76,11 +92,20 @@ async function DescribeSubscriptionFilters(client, stateConnector, context) {
|
|
|
76
92
|
const cmd = new DescribeSubscriptionFiltersCommand(preparedParams);
|
|
77
93
|
const result = await client.send(cmd);
|
|
78
94
|
state.push({
|
|
79
|
-
_metadata: {
|
|
95
|
+
_metadata: {
|
|
96
|
+
account: context.account,
|
|
97
|
+
region: context.region,
|
|
98
|
+
timestamp: Date.now()
|
|
99
|
+
},
|
|
80
100
|
_parameters: preparedParams,
|
|
81
101
|
_result: result
|
|
82
102
|
});
|
|
83
103
|
pagingToken = result.nextToken;
|
|
104
|
+
if (pagingToken != null) {
|
|
105
|
+
getterDebug("Found pagination token in response");
|
|
106
|
+
} else {
|
|
107
|
+
getterDebug("No pagination token found in response");
|
|
108
|
+
}
|
|
84
109
|
} catch (err) {
|
|
85
110
|
if (err instanceof CloudWatchLogsServiceException) {
|
|
86
111
|
if (err?.$retryable) {
|
|
@@ -95,6 +120,7 @@ async function DescribeSubscriptionFilters(client, stateConnector, context) {
|
|
|
95
120
|
}
|
|
96
121
|
} while (pagingToken != null);
|
|
97
122
|
}
|
|
123
|
+
getterDebug("Recording state");
|
|
98
124
|
await stateConnector.onServiceScanCompleteCallback(
|
|
99
125
|
context.account,
|
|
100
126
|
context.region,
|
|
@@ -106,25 +132,18 @@ async function DescribeSubscriptionFilters(client, stateConnector, context) {
|
|
|
106
132
|
|
|
107
133
|
// src/generated/graph.ts
|
|
108
134
|
import {
|
|
109
|
-
evaluateSelector,
|
|
110
|
-
formatNode,
|
|
111
135
|
evaluateSelectorGlobally,
|
|
112
136
|
filterState,
|
|
113
137
|
formatEdge
|
|
114
138
|
} from "@infrascan/core";
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
const DescribeSubscriptionFiltersNodes = await evaluateSelector(
|
|
118
|
-
context.account,
|
|
119
|
-
context.region,
|
|
120
|
-
"CloudWatchLogs|DescribeSubscriptionFilters|[]._result.subscriptionFilters[].{id:logGroupName,name:logGroupName}",
|
|
121
|
-
stateConnector
|
|
122
|
-
);
|
|
123
|
-
state.push(...DescribeSubscriptionFiltersNodes);
|
|
124
|
-
return state.map((node) => formatNode(node, "CloudWatchLogs", context, true));
|
|
125
|
-
}
|
|
139
|
+
import debug3 from "debug";
|
|
140
|
+
var edgesDebug = debug3("cloudwatch-logs:edges");
|
|
126
141
|
async function getEdges(stateConnector) {
|
|
142
|
+
edgesDebug("Fetching edges");
|
|
127
143
|
const edges = [];
|
|
144
|
+
edgesDebug(
|
|
145
|
+
"Evaluating CloudWatchLogs|DescribeSubscriptionFilters|[]._result.subscriptionFilters[]"
|
|
146
|
+
);
|
|
128
147
|
const DescribeSubscriptionFiltersState1 = await evaluateSelectorGlobally(
|
|
129
148
|
"CloudWatchLogs|DescribeSubscriptionFilters|[]._result.subscriptionFilters[]",
|
|
130
149
|
stateConnector
|
|
@@ -140,10 +159,108 @@ async function getEdges(stateConnector) {
|
|
|
140
159
|
}
|
|
141
160
|
return formatEdge(source, target);
|
|
142
161
|
});
|
|
162
|
+
edgesDebug(
|
|
163
|
+
`Evaluated CloudWatchLogs|DescribeSubscriptionFilters|[]._result.subscriptionFilters[]: ${DescribeSubscriptionFiltersEdges1.length} Edges found`
|
|
164
|
+
);
|
|
143
165
|
edges.push(...DescribeSubscriptionFiltersEdges1);
|
|
144
166
|
return edges;
|
|
145
167
|
}
|
|
146
168
|
|
|
169
|
+
// src/graph.ts
|
|
170
|
+
import { evaluateSelector, toLowerCase, Time, Size } from "@infrascan/core";
|
|
171
|
+
var CloudwatchLogGroupEntity = {
|
|
172
|
+
version: "0.1.0",
|
|
173
|
+
debugLabel: "cloudwatch-logs",
|
|
174
|
+
provider: "aws",
|
|
175
|
+
command: "DescribeLogGroups",
|
|
176
|
+
category: "cloudwatch",
|
|
177
|
+
subcategory: "logs",
|
|
178
|
+
nodeType: "cloudwatch-logs",
|
|
179
|
+
selector: "CloudWatchLogs|DescribeLogGroups|[]",
|
|
180
|
+
getState(state, context) {
|
|
181
|
+
return evaluateSelector(
|
|
182
|
+
context.account,
|
|
183
|
+
context.region,
|
|
184
|
+
CloudwatchLogGroupEntity.selector,
|
|
185
|
+
state
|
|
186
|
+
);
|
|
187
|
+
},
|
|
188
|
+
translate(val) {
|
|
189
|
+
return (val._result.logGroups ?? []).map(
|
|
190
|
+
(group) => Object.assign(group, {
|
|
191
|
+
$metadata: val._metadata,
|
|
192
|
+
$parameters: val._parameters
|
|
193
|
+
})
|
|
194
|
+
);
|
|
195
|
+
},
|
|
196
|
+
components: {
|
|
197
|
+
$metadata(val) {
|
|
198
|
+
return {
|
|
199
|
+
version: CloudwatchLogGroupEntity.version,
|
|
200
|
+
timestamp: val.$metadata.timestamp
|
|
201
|
+
};
|
|
202
|
+
},
|
|
203
|
+
$graph(val) {
|
|
204
|
+
return {
|
|
205
|
+
id: val.logGroupArn ?? val.arn,
|
|
206
|
+
label: val.logGroupName,
|
|
207
|
+
nodeType: CloudwatchLogGroupEntity.nodeType
|
|
208
|
+
};
|
|
209
|
+
},
|
|
210
|
+
$source(val) {
|
|
211
|
+
return {
|
|
212
|
+
command: CloudwatchLogGroupEntity.command,
|
|
213
|
+
parameters: val.$parameters
|
|
214
|
+
};
|
|
215
|
+
},
|
|
216
|
+
tenant(val) {
|
|
217
|
+
return {
|
|
218
|
+
tenantId: val.$metadata.account,
|
|
219
|
+
provider: CloudwatchLogGroupEntity.provider,
|
|
220
|
+
partition: val.$metadata.partition
|
|
221
|
+
};
|
|
222
|
+
},
|
|
223
|
+
location(val) {
|
|
224
|
+
return {
|
|
225
|
+
code: val.$metadata.region
|
|
226
|
+
};
|
|
227
|
+
},
|
|
228
|
+
resource(val) {
|
|
229
|
+
return {
|
|
230
|
+
id: val.logGroupArn,
|
|
231
|
+
name: val.logGroupName,
|
|
232
|
+
category: CloudwatchLogGroupEntity.category,
|
|
233
|
+
subcategory: CloudwatchLogGroupEntity.subcategory
|
|
234
|
+
};
|
|
235
|
+
},
|
|
236
|
+
audit(val) {
|
|
237
|
+
return {
|
|
238
|
+
createdAt: val.creationTime != null ? new Date(val.creationTime) : void 0
|
|
239
|
+
};
|
|
240
|
+
},
|
|
241
|
+
encryption(val) {
|
|
242
|
+
return {
|
|
243
|
+
keyId: val.kmsKeyId
|
|
244
|
+
};
|
|
245
|
+
},
|
|
246
|
+
logGroup(val) {
|
|
247
|
+
return {
|
|
248
|
+
accessClass: val.logGroupClass != null ? toLowerCase(val.logGroupClass) : void 0,
|
|
249
|
+
dataProtectionStatus: val.dataProtectionStatus != null ? toLowerCase(val.dataProtectionStatus) : void 0,
|
|
250
|
+
retentionPeriod: val.retentionInDays != null ? {
|
|
251
|
+
unit: Time.Days,
|
|
252
|
+
value: val.retentionInDays
|
|
253
|
+
} : void 0,
|
|
254
|
+
size: val.storedBytes != null ? {
|
|
255
|
+
unit: Size.Bytes,
|
|
256
|
+
value: val.storedBytes
|
|
257
|
+
} : void 0,
|
|
258
|
+
metricFilterCount: val.metricFilterCount
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
|
|
147
264
|
// src/index.ts
|
|
148
265
|
var CloudWatchLogsScanner = {
|
|
149
266
|
provider: "aws",
|
|
@@ -153,10 +270,10 @@ var CloudWatchLogsScanner = {
|
|
|
153
270
|
getClient,
|
|
154
271
|
callPerRegion: true,
|
|
155
272
|
getters: [DescribeLogGroups, DescribeSubscriptionFilters],
|
|
156
|
-
|
|
157
|
-
|
|
273
|
+
getEdges,
|
|
274
|
+
entities: [CloudwatchLogGroupEntity]
|
|
158
275
|
};
|
|
159
|
-
var
|
|
276
|
+
var index_default = CloudWatchLogsScanner;
|
|
160
277
|
export {
|
|
161
|
-
|
|
278
|
+
index_default as default
|
|
162
279
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@infrascan/aws-cloudwatch-logs-scanner",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Infrascan scanner definition for AWS Cloudwatch Logs",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -8,8 +8,7 @@
|
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
10
|
"require": "./dist/index.js",
|
|
11
|
-
"import": "./dist/index.mjs"
|
|
12
|
-
"types": "./dist/index.d.ts"
|
|
11
|
+
"import": "./dist/index.mjs"
|
|
13
12
|
}
|
|
14
13
|
},
|
|
15
14
|
"files": [
|
|
@@ -42,17 +41,19 @@
|
|
|
42
41
|
},
|
|
43
42
|
"homepage": "https://github.com/infrascan/infrascan#readme",
|
|
44
43
|
"devDependencies": {
|
|
45
|
-
"@aws-sdk/credential-providers": "
|
|
44
|
+
"@aws-sdk/credential-providers": "3.624.0",
|
|
46
45
|
"@infrascan/aws-codegen": "^0.1.0",
|
|
47
|
-
"@infrascan/fs-connector": "^0.
|
|
48
|
-
"@infrascan/shared-types": "^0.
|
|
46
|
+
"@infrascan/fs-connector": "^0.3.0",
|
|
47
|
+
"@infrascan/shared-types": "^0.6.0",
|
|
49
48
|
"@infrascan/tsconfig": "*",
|
|
50
49
|
"aws-sdk-client-mock": "^3.0.0",
|
|
51
50
|
"eslint-config-codegen": "^1.0.0",
|
|
52
|
-
"tap": "^18.7.0"
|
|
51
|
+
"tap": "^18.7.0",
|
|
52
|
+
"@types/debug": "^4"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@aws-sdk/client-cloudwatch-logs": "3.
|
|
56
|
-
"@infrascan/core": "0.
|
|
55
|
+
"@aws-sdk/client-cloudwatch-logs": "3.624.0",
|
|
56
|
+
"@infrascan/core": "0.5.0",
|
|
57
|
+
"debug": "^4"
|
|
57
58
|
}
|
|
58
59
|
}
|