@factiii/stack 0.1.2 → 0.1.8
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/bin/factiii +13 -0
- package/dist/cli/pr-check.d.ts +24 -0
- package/dist/cli/pr-check.d.ts.map +1 -0
- package/dist/cli/pr-check.js +153 -0
- package/dist/cli/pr-check.js.map +1 -0
- package/dist/plugins/addons/server-mode/index.d.ts.map +1 -1
- package/dist/plugins/addons/server-mode/index.js +3 -0
- package/dist/plugins/addons/server-mode/index.js.map +1 -1
- package/dist/plugins/addons/server-mode/scanfix/mac.d.ts +20 -3
- package/dist/plugins/addons/server-mode/scanfix/mac.d.ts.map +1 -1
- package/dist/plugins/addons/server-mode/scanfix/mac.js +304 -177
- package/dist/plugins/addons/server-mode/scanfix/mac.js.map +1 -1
- package/dist/plugins/addons/server-mode/scanfix/tart.d.ts +19 -0
- package/dist/plugins/addons/server-mode/scanfix/tart.d.ts.map +1 -0
- package/dist/plugins/addons/server-mode/scanfix/tart.js +350 -0
- package/dist/plugins/addons/server-mode/scanfix/tart.js.map +1 -0
- package/dist/plugins/pipelines/aws/configs/free-tier.d.ts.map +1 -1
- package/dist/plugins/pipelines/aws/configs/free-tier.js +3 -38
- package/dist/plugins/pipelines/aws/configs/free-tier.js.map +1 -1
- package/dist/plugins/pipelines/aws/index.d.ts +4 -1
- package/dist/plugins/pipelines/aws/index.d.ts.map +1 -1
- package/dist/plugins/pipelines/aws/index.js +101 -29
- package/dist/plugins/pipelines/aws/index.js.map +1 -1
- package/dist/plugins/pipelines/aws/scanfix/credentials.d.ts +9 -0
- package/dist/plugins/pipelines/aws/scanfix/credentials.d.ts.map +1 -0
- package/dist/plugins/pipelines/aws/scanfix/credentials.js +196 -0
- package/dist/plugins/pipelines/aws/scanfix/credentials.js.map +1 -0
- package/dist/plugins/pipelines/aws/scanfix/db-replication.d.ts +13 -0
- package/dist/plugins/pipelines/aws/scanfix/db-replication.d.ts.map +1 -0
- package/dist/plugins/pipelines/aws/scanfix/db-replication.js +136 -0
- package/dist/plugins/pipelines/aws/scanfix/db-replication.js.map +1 -0
- package/dist/plugins/pipelines/aws/scanfix/ec2.d.ts +10 -0
- package/dist/plugins/pipelines/aws/scanfix/ec2.d.ts.map +1 -0
- package/dist/plugins/pipelines/aws/scanfix/ec2.js +279 -0
- package/dist/plugins/pipelines/aws/scanfix/ec2.js.map +1 -0
- package/dist/plugins/pipelines/aws/scanfix/ecr.d.ts +9 -0
- package/dist/plugins/pipelines/aws/scanfix/ecr.d.ts.map +1 -0
- package/dist/plugins/pipelines/aws/scanfix/ecr.js +100 -0
- package/dist/plugins/pipelines/aws/scanfix/ecr.js.map +1 -0
- package/dist/plugins/pipelines/aws/scanfix/iam.d.ts +10 -0
- package/dist/plugins/pipelines/aws/scanfix/iam.d.ts.map +1 -0
- package/dist/plugins/pipelines/aws/scanfix/iam.js +255 -0
- package/dist/plugins/pipelines/aws/scanfix/iam.js.map +1 -0
- package/dist/plugins/pipelines/aws/scanfix/rds.d.ts +10 -0
- package/dist/plugins/pipelines/aws/scanfix/rds.d.ts.map +1 -0
- package/dist/plugins/pipelines/aws/scanfix/rds.js +261 -0
- package/dist/plugins/pipelines/aws/scanfix/rds.js.map +1 -0
- package/dist/plugins/pipelines/aws/scanfix/s3.d.ts +9 -0
- package/dist/plugins/pipelines/aws/scanfix/s3.d.ts.map +1 -0
- package/dist/plugins/pipelines/aws/scanfix/s3.js +134 -0
- package/dist/plugins/pipelines/aws/scanfix/s3.js.map +1 -0
- package/dist/plugins/pipelines/aws/scanfix/security-groups.d.ts +10 -0
- package/dist/plugins/pipelines/aws/scanfix/security-groups.d.ts.map +1 -0
- package/dist/plugins/pipelines/aws/scanfix/security-groups.js +225 -0
- package/dist/plugins/pipelines/aws/scanfix/security-groups.js.map +1 -0
- package/dist/plugins/pipelines/aws/scanfix/ses.d.ts +9 -0
- package/dist/plugins/pipelines/aws/scanfix/ses.d.ts.map +1 -0
- package/dist/plugins/pipelines/aws/scanfix/ses.js +174 -0
- package/dist/plugins/pipelines/aws/scanfix/ses.js.map +1 -0
- package/dist/plugins/pipelines/aws/scanfix/vpc.d.ts +9 -0
- package/dist/plugins/pipelines/aws/scanfix/vpc.d.ts.map +1 -0
- package/dist/plugins/pipelines/aws/scanfix/vpc.js +237 -0
- package/dist/plugins/pipelines/aws/scanfix/vpc.js.map +1 -0
- package/dist/plugins/pipelines/aws/utils/aws-helpers.d.ts +50 -0
- package/dist/plugins/pipelines/aws/utils/aws-helpers.d.ts.map +1 -0
- package/dist/plugins/pipelines/aws/utils/aws-helpers.js +137 -0
- package/dist/plugins/pipelines/aws/utils/aws-helpers.js.map +1 -0
- package/dist/plugins/pipelines/factiii/index.d.ts.map +1 -1
- package/dist/plugins/pipelines/factiii/index.js +11 -0
- package/dist/plugins/pipelines/factiii/index.js.map +1 -1
- package/dist/plugins/pipelines/factiii/pr-check.d.ts +35 -0
- package/dist/plugins/pipelines/factiii/pr-check.d.ts.map +1 -0
- package/dist/plugins/pipelines/factiii/pr-check.js +202 -0
- package/dist/plugins/pipelines/factiii/pr-check.js.map +1 -0
- package/dist/plugins/pipelines/factiii/utils/workflows.d.ts.map +1 -1
- package/dist/plugins/pipelines/factiii/utils/workflows.js +1 -0
- package/dist/plugins/pipelines/factiii/utils/workflows.js.map +1 -1
- package/dist/plugins/pipelines/factiii/workflows/factiii-cicd-staging.yml +8 -3
- package/dist/plugins/pipelines/factiii/workflows/factiii-pr-check.yml +103 -0
- package/dist/plugins/servers/mac/staging.d.ts.map +1 -1
- package/dist/plugins/servers/mac/staging.js +304 -52
- package/dist/plugins/servers/mac/staging.js.map +1 -1
- package/dist/types/config.d.ts +11 -0
- package/dist/types/config.d.ts.map +1 -1
- package/dist/utils/github-status.d.ts +39 -0
- package/dist/utils/github-status.d.ts.map +1 -0
- package/dist/utils/github-status.js +172 -0
- package/dist/utils/github-status.js.map +1 -0
- package/package.json +3 -3
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* AWS EC2 Fixes
|
|
4
|
+
*
|
|
5
|
+
* Provisions EC2 key pair, instance, and Elastic IP.
|
|
6
|
+
* Uses Ubuntu 22.04 AMI, t2.micro (free tier), public subnet.
|
|
7
|
+
* Key pair private key is stored in Ansible Vault.
|
|
8
|
+
*/
|
|
9
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
12
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
13
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
14
|
+
}
|
|
15
|
+
Object.defineProperty(o, k2, desc);
|
|
16
|
+
}) : (function(o, m, k, k2) {
|
|
17
|
+
if (k2 === undefined) k2 = k;
|
|
18
|
+
o[k2] = m[k];
|
|
19
|
+
}));
|
|
20
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
21
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
22
|
+
}) : function(o, v) {
|
|
23
|
+
o["default"] = v;
|
|
24
|
+
});
|
|
25
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
26
|
+
var ownKeys = function(o) {
|
|
27
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
28
|
+
var ar = [];
|
|
29
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
30
|
+
return ar;
|
|
31
|
+
};
|
|
32
|
+
return ownKeys(o);
|
|
33
|
+
};
|
|
34
|
+
return function (mod) {
|
|
35
|
+
if (mod && mod.__esModule) return mod;
|
|
36
|
+
var result = {};
|
|
37
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
38
|
+
__setModuleDefault(result, mod);
|
|
39
|
+
return result;
|
|
40
|
+
};
|
|
41
|
+
})();
|
|
42
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
|
+
exports.ec2Fixes = void 0;
|
|
44
|
+
const aws_helpers_js_1 = require("../utils/aws-helpers.js");
|
|
45
|
+
/**
|
|
46
|
+
* Find VPC by factiii:project tag
|
|
47
|
+
*/
|
|
48
|
+
function findVpc(projectName, region) {
|
|
49
|
+
const result = (0, aws_helpers_js_1.awsExecSafe)('aws ec2 describe-vpcs --filters "Name=tag:factiii:project,Values=' + projectName + '" --query "Vpcs[0].VpcId" --output text', region);
|
|
50
|
+
if (!result || result === 'None' || result === 'null')
|
|
51
|
+
return null;
|
|
52
|
+
return result.replace(/"/g, '');
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Find subnet by tag and type
|
|
56
|
+
*/
|
|
57
|
+
function findSubnet(projectName, region, type) {
|
|
58
|
+
const result = (0, aws_helpers_js_1.awsExecSafe)('aws ec2 describe-subnets --filters "Name=tag:factiii:project,Values=' + projectName + '" "Name=tag:factiii:subnet-type,Values=' + type + '" --query "Subnets[0].SubnetId" --output text', region);
|
|
59
|
+
if (!result || result === 'None' || result === 'null')
|
|
60
|
+
return null;
|
|
61
|
+
return result.replace(/"/g, '');
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Find security group by name and VPC
|
|
65
|
+
*/
|
|
66
|
+
function findSecurityGroup(groupName, vpcId, region) {
|
|
67
|
+
const result = (0, aws_helpers_js_1.awsExecSafe)('aws ec2 describe-security-groups --filters "Name=group-name,Values=' + groupName + '" "Name=vpc-id,Values=' + vpcId + '" --query "SecurityGroups[0].GroupId" --output text', region);
|
|
68
|
+
if (!result || result === 'None' || result === 'null')
|
|
69
|
+
return null;
|
|
70
|
+
return result.replace(/"/g, '');
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Find EC2 key pair by name
|
|
74
|
+
*/
|
|
75
|
+
function findKeyPair(keyName, region) {
|
|
76
|
+
const result = (0, aws_helpers_js_1.awsExecSafe)('aws ec2 describe-key-pairs --key-names ' + keyName + ' --query "KeyPairs[0].KeyPairId" --output text', region);
|
|
77
|
+
return !!result && result !== 'None' && result !== 'null';
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Find running EC2 instance by tag
|
|
81
|
+
*/
|
|
82
|
+
function findInstance(projectName, region) {
|
|
83
|
+
const result = (0, aws_helpers_js_1.awsExecSafe)('aws ec2 describe-instances --filters "Name=tag:factiii:project,Values=' + projectName + '" "Name=instance-state-name,Values=running,stopped" --query "Reservations[0].Instances[0].InstanceId" --output text', region);
|
|
84
|
+
if (!result || result === 'None' || result === 'null')
|
|
85
|
+
return null;
|
|
86
|
+
return result.replace(/"/g, '');
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Find Elastic IP associated with an instance
|
|
90
|
+
*/
|
|
91
|
+
function findElasticIp(instanceId, region) {
|
|
92
|
+
const result = (0, aws_helpers_js_1.awsExecSafe)('aws ec2 describe-addresses --filters "Name=instance-id,Values=' + instanceId + '" --query "Addresses[0].PublicIp" --output text', region);
|
|
93
|
+
if (!result || result === 'None' || result === 'null')
|
|
94
|
+
return null;
|
|
95
|
+
return result.replace(/"/g, '');
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Get latest Ubuntu 22.04 AMI for the region
|
|
99
|
+
*/
|
|
100
|
+
function getUbuntuAmi(region) {
|
|
101
|
+
const result = (0, aws_helpers_js_1.awsExecSafe)('aws ec2 describe-images --owners 099720109477 --filters "Name=name,Values=ubuntu/images/hvm-ssd/ubuntu-jammy-22.04-amd64-server-*" "Name=state,Values=available" --query "sort_by(Images, &CreationDate)[-1].ImageId" --output text', region);
|
|
102
|
+
if (!result || result === 'None' || result === 'null')
|
|
103
|
+
return null;
|
|
104
|
+
return result.replace(/"/g, '');
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Check if AWS is configured for this project
|
|
108
|
+
*/
|
|
109
|
+
function isAwsConfigured(config) {
|
|
110
|
+
if (config.aws)
|
|
111
|
+
return true;
|
|
112
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
113
|
+
const { extractEnvironments } = require('../../../../utils/config-helpers.js');
|
|
114
|
+
const environments = extractEnvironments(config);
|
|
115
|
+
return Object.values(environments).some((e) => e.pipeline === 'aws');
|
|
116
|
+
}
|
|
117
|
+
exports.ec2Fixes = [
|
|
118
|
+
{
|
|
119
|
+
id: 'aws-keypair-missing',
|
|
120
|
+
stage: 'prod',
|
|
121
|
+
severity: 'critical',
|
|
122
|
+
description: 'EC2 key pair not created for SSH access',
|
|
123
|
+
scan: async (config) => {
|
|
124
|
+
if (!isAwsConfigured(config))
|
|
125
|
+
return false;
|
|
126
|
+
const { region } = (0, aws_helpers_js_1.getAwsConfig)(config);
|
|
127
|
+
const projectName = (0, aws_helpers_js_1.getProjectName)(config);
|
|
128
|
+
return !findKeyPair('factiii-' + projectName, region);
|
|
129
|
+
},
|
|
130
|
+
fix: async (config) => {
|
|
131
|
+
const { region } = (0, aws_helpers_js_1.getAwsConfig)(config);
|
|
132
|
+
const projectName = (0, aws_helpers_js_1.getProjectName)(config);
|
|
133
|
+
const keyName = 'factiii-' + projectName;
|
|
134
|
+
try {
|
|
135
|
+
// Create key pair — AWS returns the private key material
|
|
136
|
+
const result = (0, aws_helpers_js_1.awsExec)('aws ec2 create-key-pair --key-name ' + keyName + ' --key-type ed25519 --query "KeyMaterial" --output text', region);
|
|
137
|
+
// Save private key to ~/.ssh/prod_deploy_key
|
|
138
|
+
const os = await Promise.resolve().then(() => __importStar(require('os')));
|
|
139
|
+
const fs = await Promise.resolve().then(() => __importStar(require('fs')));
|
|
140
|
+
const path = await Promise.resolve().then(() => __importStar(require('path')));
|
|
141
|
+
const sshDir = path.join(os.homedir(), '.ssh');
|
|
142
|
+
if (!fs.existsSync(sshDir)) {
|
|
143
|
+
fs.mkdirSync(sshDir, { mode: 0o700 });
|
|
144
|
+
}
|
|
145
|
+
const keyPath = path.join(sshDir, 'prod_deploy_key');
|
|
146
|
+
fs.writeFileSync(keyPath, result + '\n', { mode: 0o600 });
|
|
147
|
+
console.log(' Created key pair: ' + keyName);
|
|
148
|
+
console.log(' Private key saved to: ' + keyPath);
|
|
149
|
+
// Store in Ansible Vault if configured
|
|
150
|
+
if (config.ansible?.vault_path) {
|
|
151
|
+
console.log(' TIP: Add this key to Ansible Vault with: npx factiii secrets edit');
|
|
152
|
+
}
|
|
153
|
+
return true;
|
|
154
|
+
}
|
|
155
|
+
catch (e) {
|
|
156
|
+
console.log(' Failed to create key pair: ' + (e instanceof Error ? e.message : String(e)));
|
|
157
|
+
return false;
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
manualFix: 'Create key pair: aws ec2 create-key-pair --key-name factiii-{name} --key-type ed25519',
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
id: 'aws-ec2-instance-missing',
|
|
164
|
+
stage: 'prod',
|
|
165
|
+
severity: 'critical',
|
|
166
|
+
description: 'EC2 instance not created (Ubuntu 22.04, t2.micro)',
|
|
167
|
+
scan: async (config) => {
|
|
168
|
+
if (!isAwsConfigured(config))
|
|
169
|
+
return false;
|
|
170
|
+
const { region } = (0, aws_helpers_js_1.getAwsConfig)(config);
|
|
171
|
+
const projectName = (0, aws_helpers_js_1.getProjectName)(config);
|
|
172
|
+
return !findInstance(projectName, region);
|
|
173
|
+
},
|
|
174
|
+
fix: async (config) => {
|
|
175
|
+
const { region } = (0, aws_helpers_js_1.getAwsConfig)(config);
|
|
176
|
+
const projectName = (0, aws_helpers_js_1.getProjectName)(config);
|
|
177
|
+
const vpcId = findVpc(projectName, region);
|
|
178
|
+
if (!vpcId) {
|
|
179
|
+
console.log(' VPC must be created first');
|
|
180
|
+
return false;
|
|
181
|
+
}
|
|
182
|
+
const publicSubnet = findSubnet(projectName, region, 'public');
|
|
183
|
+
if (!publicSubnet) {
|
|
184
|
+
console.log(' Public subnet must be created first');
|
|
185
|
+
return false;
|
|
186
|
+
}
|
|
187
|
+
const ec2SgId = findSecurityGroup('factiii-' + projectName + '-ec2', vpcId, region);
|
|
188
|
+
if (!ec2SgId) {
|
|
189
|
+
console.log(' EC2 security group must be created first');
|
|
190
|
+
return false;
|
|
191
|
+
}
|
|
192
|
+
const keyName = 'factiii-' + projectName;
|
|
193
|
+
if (!findKeyPair(keyName, region)) {
|
|
194
|
+
console.log(' Key pair must be created first');
|
|
195
|
+
return false;
|
|
196
|
+
}
|
|
197
|
+
try {
|
|
198
|
+
// Get latest Ubuntu 22.04 AMI
|
|
199
|
+
const amiId = getUbuntuAmi(region);
|
|
200
|
+
if (!amiId) {
|
|
201
|
+
console.log(' Failed to find Ubuntu 22.04 AMI for region ' + region);
|
|
202
|
+
return false;
|
|
203
|
+
}
|
|
204
|
+
console.log(' Using AMI: ' + amiId);
|
|
205
|
+
// Launch instance
|
|
206
|
+
const instanceResult = (0, aws_helpers_js_1.awsExec)('aws ec2 run-instances' +
|
|
207
|
+
' --image-id ' + amiId +
|
|
208
|
+
' --instance-type t2.micro' +
|
|
209
|
+
' --key-name ' + keyName +
|
|
210
|
+
' --security-group-ids ' + ec2SgId +
|
|
211
|
+
' --subnet-id ' + publicSubnet +
|
|
212
|
+
' --count 1' +
|
|
213
|
+
' ' + (0, aws_helpers_js_1.tagSpec)('instance', projectName), region);
|
|
214
|
+
const instanceId = JSON.parse(instanceResult).Instances[0].InstanceId;
|
|
215
|
+
console.log(' Launched EC2 instance: ' + instanceId);
|
|
216
|
+
console.log(' Instance type: t2.micro (free tier eligible)');
|
|
217
|
+
console.log(' Waiting for instance to be running...');
|
|
218
|
+
// Wait for instance to be running
|
|
219
|
+
(0, aws_helpers_js_1.awsExec)('aws ec2 wait instance-running --instance-ids ' + instanceId, region);
|
|
220
|
+
// Get public IP
|
|
221
|
+
const ipResult = (0, aws_helpers_js_1.awsExecSafe)('aws ec2 describe-instances --instance-ids ' + instanceId + ' --query "Reservations[0].Instances[0].PublicIpAddress" --output text', region);
|
|
222
|
+
if (ipResult && ipResult !== 'None') {
|
|
223
|
+
console.log(' Public IP: ' + ipResult.replace(/"/g, ''));
|
|
224
|
+
console.log(' NOTE: This IP will change on restart. Run fix again for Elastic IP.');
|
|
225
|
+
}
|
|
226
|
+
return true;
|
|
227
|
+
}
|
|
228
|
+
catch (e) {
|
|
229
|
+
console.log(' Failed to launch EC2 instance: ' + (e instanceof Error ? e.message : String(e)));
|
|
230
|
+
return false;
|
|
231
|
+
}
|
|
232
|
+
},
|
|
233
|
+
manualFix: 'Launch EC2: aws ec2 run-instances --image-id <ubuntu-ami> --instance-type t2.micro --key-name factiii-{name}',
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
id: 'aws-ec2-elastic-ip',
|
|
237
|
+
stage: 'prod',
|
|
238
|
+
severity: 'warning',
|
|
239
|
+
description: 'Elastic IP not assigned to EC2 instance (IP changes on restart)',
|
|
240
|
+
scan: async (config) => {
|
|
241
|
+
if (!isAwsConfigured(config))
|
|
242
|
+
return false;
|
|
243
|
+
const { region } = (0, aws_helpers_js_1.getAwsConfig)(config);
|
|
244
|
+
const projectName = (0, aws_helpers_js_1.getProjectName)(config);
|
|
245
|
+
const instanceId = findInstance(projectName, region);
|
|
246
|
+
if (!instanceId)
|
|
247
|
+
return false; // Instance must exist first
|
|
248
|
+
return !findElasticIp(instanceId, region);
|
|
249
|
+
},
|
|
250
|
+
fix: async (config) => {
|
|
251
|
+
const { region } = (0, aws_helpers_js_1.getAwsConfig)(config);
|
|
252
|
+
const projectName = (0, aws_helpers_js_1.getProjectName)(config);
|
|
253
|
+
const instanceId = findInstance(projectName, region);
|
|
254
|
+
if (!instanceId) {
|
|
255
|
+
console.log(' EC2 instance must be created first');
|
|
256
|
+
return false;
|
|
257
|
+
}
|
|
258
|
+
try {
|
|
259
|
+
// Allocate Elastic IP
|
|
260
|
+
const eipResult = (0, aws_helpers_js_1.awsExec)('aws ec2 allocate-address --domain vpc ' + (0, aws_helpers_js_1.tagSpec)('elastic-ip', projectName), region);
|
|
261
|
+
const parsed = JSON.parse(eipResult);
|
|
262
|
+
const allocationId = parsed.AllocationId;
|
|
263
|
+
const publicIp = parsed.PublicIp;
|
|
264
|
+
console.log(' Allocated Elastic IP: ' + publicIp);
|
|
265
|
+
// Associate with instance
|
|
266
|
+
(0, aws_helpers_js_1.awsExec)('aws ec2 associate-address --allocation-id ' + allocationId + ' --instance-id ' + instanceId, region);
|
|
267
|
+
console.log(' Associated with instance: ' + instanceId);
|
|
268
|
+
console.log(' Update factiii.yml prod.domain to: ' + publicIp);
|
|
269
|
+
return true;
|
|
270
|
+
}
|
|
271
|
+
catch (e) {
|
|
272
|
+
console.log(' Failed to allocate Elastic IP: ' + (e instanceof Error ? e.message : String(e)));
|
|
273
|
+
return false;
|
|
274
|
+
}
|
|
275
|
+
},
|
|
276
|
+
manualFix: 'Allocate Elastic IP and associate with EC2 instance',
|
|
277
|
+
},
|
|
278
|
+
];
|
|
279
|
+
//# sourceMappingURL=ec2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ec2.js","sourceRoot":"","sources":["../../../../../src/plugins/pipelines/aws/scanfix/ec2.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGH,4DAAsG;AAEtG;;GAEG;AACH,SAAS,OAAO,CAAC,WAAmB,EAAE,MAAc;IAClD,MAAM,MAAM,GAAG,IAAA,4BAAW,EACxB,mEAAmE,GAAG,WAAW,GAAG,yCAAyC,EAC7H,MAAM,CACP,CAAC;IACF,IAAI,CAAC,MAAM,IAAI,MAAM,KAAK,MAAM,IAAI,MAAM,KAAK,MAAM;QAAE,OAAO,IAAI,CAAC;IACnE,OAAO,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;AAClC,CAAC;AAED;;GAEG;AACH,SAAS,UAAU,CAAC,WAAmB,EAAE,MAAc,EAAE,IAAY;IACnE,MAAM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C,GAAG,CAAC,2BAA2B,GAAG,QAAQ,CAAC,CAAC;gBAEpD,0BAA0B;gBAC1B,IAAA,wBAAO,EACL,4CAA4C,GAAG,YAAY,GAAG,iBAAiB,GAAG,UAAU,EAC5F,MAAM,CACP,CAAC;gBACF,OAAO,CAAC,GAAG,CAAC,+BAA+B,GAAG,UAAU,CAAC,CAAC;gBAC1D,OAAO,CAAC,GAAG,CAAC,wCAAwC,GAAG,QAAQ,CAAC,CAAC;gBAEjE,OAAO,IAAI,CAAC;YACd,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACX,OAAO,CAAC,GAAG,CAAC,oCAAoC,GAAG,CAAC,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;gBACjG,OAAO,KAAK,CAAC;YACf,CAAC;QACH,CAAC;QACD,SAAS,EAAE,qDAAqD;KACjE;CACF,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AWS ECR Fixes
|
|
3
|
+
*
|
|
4
|
+
* Provisions ECR (Elastic Container Registry) repository
|
|
5
|
+
* with lifecycle policy to keep costs down.
|
|
6
|
+
*/
|
|
7
|
+
import type { Fix } from '../../../../types/index.js';
|
|
8
|
+
export declare const ecrFixes: Fix[];
|
|
9
|
+
//# sourceMappingURL=ecr.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ecr.d.ts","sourceRoot":"","sources":["../../../../../src/plugins/pipelines/aws/scanfix/ecr.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAiB,GAAG,EAAE,MAAM,4BAA4B,CAAC;AA2BrE,eAAO,MAAM,QAAQ,EAAE,GAAG,EAgFzB,CAAC"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* AWS ECR Fixes
|
|
4
|
+
*
|
|
5
|
+
* Provisions ECR (Elastic Container Registry) repository
|
|
6
|
+
* with lifecycle policy to keep costs down.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.ecrFixes = void 0;
|
|
10
|
+
const aws_helpers_js_1 = require("../utils/aws-helpers.js");
|
|
11
|
+
/**
|
|
12
|
+
* Check if ECR repository exists
|
|
13
|
+
*/
|
|
14
|
+
function findEcrRepo(repoName, region) {
|
|
15
|
+
const result = (0, aws_helpers_js_1.awsExecSafe)('aws ecr describe-repositories --repository-names ' + repoName, region);
|
|
16
|
+
return !!result && !result.includes('RepositoryNotFoundException');
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Check if AWS is configured for this project
|
|
20
|
+
*/
|
|
21
|
+
function isAwsConfigured(config) {
|
|
22
|
+
if (config.aws)
|
|
23
|
+
return true;
|
|
24
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
25
|
+
const { extractEnvironments } = require('../../../../utils/config-helpers.js');
|
|
26
|
+
const environments = extractEnvironments(config);
|
|
27
|
+
return Object.values(environments).some((e) => e.pipeline === 'aws');
|
|
28
|
+
}
|
|
29
|
+
exports.ecrFixes = [
|
|
30
|
+
{
|
|
31
|
+
id: 'aws-ecr-repo-missing',
|
|
32
|
+
stage: 'prod',
|
|
33
|
+
severity: 'warning',
|
|
34
|
+
description: 'ECR repository not created for container images',
|
|
35
|
+
scan: async (config) => {
|
|
36
|
+
if (!isAwsConfigured(config))
|
|
37
|
+
return false;
|
|
38
|
+
const { region } = (0, aws_helpers_js_1.getAwsConfig)(config);
|
|
39
|
+
const projectName = (0, aws_helpers_js_1.getProjectName)(config);
|
|
40
|
+
return !findEcrRepo(projectName, region);
|
|
41
|
+
},
|
|
42
|
+
fix: async (config) => {
|
|
43
|
+
const { region } = (0, aws_helpers_js_1.getAwsConfig)(config);
|
|
44
|
+
const projectName = (0, aws_helpers_js_1.getProjectName)(config);
|
|
45
|
+
try {
|
|
46
|
+
// Create ECR repository
|
|
47
|
+
const result = (0, aws_helpers_js_1.awsExec)('aws ecr create-repository --repository-name ' + projectName +
|
|
48
|
+
' --image-scanning-configuration scanOnPush=true', region);
|
|
49
|
+
const parsed = JSON.parse(result);
|
|
50
|
+
const repoUri = parsed.repository?.repositoryUri;
|
|
51
|
+
console.log(' Created ECR repository: ' + projectName);
|
|
52
|
+
if (repoUri) {
|
|
53
|
+
console.log(' Repository URI: ' + repoUri);
|
|
54
|
+
}
|
|
55
|
+
// Set lifecycle policy to keep only 10 images (control costs)
|
|
56
|
+
const lifecyclePolicy = JSON.stringify({
|
|
57
|
+
rules: [{
|
|
58
|
+
rulePriority: 1,
|
|
59
|
+
description: 'Keep only 10 images',
|
|
60
|
+
selection: {
|
|
61
|
+
tagStatus: 'any',
|
|
62
|
+
countType: 'imageCountMoreThan',
|
|
63
|
+
countNumber: 10,
|
|
64
|
+
},
|
|
65
|
+
action: { type: 'expire' },
|
|
66
|
+
}],
|
|
67
|
+
});
|
|
68
|
+
(0, aws_helpers_js_1.awsExec)('aws ecr put-lifecycle-policy --repository-name ' + projectName +
|
|
69
|
+
" --lifecycle-policy-text '" + lifecyclePolicy + "'", region);
|
|
70
|
+
console.log(' Set lifecycle policy: keep 10 most recent images');
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
catch (e) {
|
|
74
|
+
console.log(' Failed to create ECR repository: ' + (e instanceof Error ? e.message : String(e)));
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
manualFix: 'Create ECR repository: aws ecr create-repository --repository-name <app-name>',
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
id: 'aws-ecr-login-test',
|
|
82
|
+
stage: 'dev',
|
|
83
|
+
severity: 'info',
|
|
84
|
+
description: 'ECR Docker login not working from dev machine',
|
|
85
|
+
scan: async (config) => {
|
|
86
|
+
if (!isAwsConfigured(config))
|
|
87
|
+
return false;
|
|
88
|
+
const { region } = (0, aws_helpers_js_1.getAwsConfig)(config);
|
|
89
|
+
const projectName = (0, aws_helpers_js_1.getProjectName)(config);
|
|
90
|
+
if (!findEcrRepo(projectName, region))
|
|
91
|
+
return false;
|
|
92
|
+
// Test ECR login
|
|
93
|
+
const result = (0, aws_helpers_js_1.awsExecSafe)('aws ecr get-login-password', region);
|
|
94
|
+
return !result;
|
|
95
|
+
},
|
|
96
|
+
fix: null,
|
|
97
|
+
manualFix: 'Test ECR login: aws ecr get-login-password --region <region> | docker login --username AWS --password-stdin <account-id>.dkr.ecr.<region>.amazonaws.com',
|
|
98
|
+
},
|
|
99
|
+
];
|
|
100
|
+
//# sourceMappingURL=ecr.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ecr.js","sourceRoot":"","sources":["../../../../../src/plugins/pipelines/aws/scanfix/ecr.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAGH,4DAA6F;AAE7F;;GAEG;AACH,SAAS,WAAW,CAAC,QAAgB,EAAE,MAAc;IACnD,MAAM,MAAM,GAAG,IAAA,4BAAW,EACxB,mDAAmD,GAAG,QAAQ,EAC9D,MAAM,CACP,CAAC;IACF,OAAO,CAAC,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,6BAA6B,CAAC,CAAC;AACrE,CAAC;AAED;;GAEG;AACH,SAAS,eAAe,CAAC,MAAqB;IAC5C,IAAI,MAAM,CAAC,GAAG;QAAE,OAAO,IAAI,CAAC;IAC5B,iEAAiE;IACjE,MAAM,EAAE,mBAAmB,EAAE,GAAG,OAAO,CAAC,qCAAqC,CAAC,CAAC;IAC/E,MAAM,YAAY,GAAG,mBAAmB,CAAC,MAAM,CAAC,CAAC;IACjD,OAAO,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,IAAI,CACrC,CAAC,CAAU,EAAE,EAAE,CAAE,CAA2B,CAAC,QAAQ,KAAK,KAAK,CAChE,CAAC;AACJ,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;QACD,GAAG,EAAE,IAAI;QACT,SAAS,EAAE,yJAAyJ;KACrK;CACF,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AWS IAM Fixes
|
|
3
|
+
*
|
|
4
|
+
* Creates IAM users with scoped policies:
|
|
5
|
+
* - Dev user: read-only access for development
|
|
6
|
+
* - Prod user: full access for deployment
|
|
7
|
+
*/
|
|
8
|
+
import type { Fix } from '../../../../types/index.js';
|
|
9
|
+
export declare const iamFixes: Fix[];
|
|
10
|
+
//# sourceMappingURL=iam.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iam.d.ts","sourceRoot":"","sources":["../../../../../src/plugins/pipelines/aws/scanfix/iam.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAiB,GAAG,EAAE,MAAM,4BAA4B,CAAC;AA0JrE,eAAO,MAAM,QAAQ,EAAE,GAAG,EA6HzB,CAAC"}
|