@mtndev/cli 2.0.0 → 2.0.1

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.
Files changed (264) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/cjs/__chunks/VH7oDXx4.cjs +28 -0
  3. package/cjs/commands/aws/ec2/allow-ip/handler.cjs +261 -12
  4. package/cjs/commands/aws/ec2/allow-ip/index.cjs +25 -55
  5. package/cjs/commands/aws/ec2/allow-ip/schema.cjs +33 -13
  6. package/cjs/commands/aws/ec2/allow-ip/utils.cjs +379 -39
  7. package/cjs/commands/aws/iam/admin-group.cjs +111 -15
  8. package/cjs/commands/aws/iam/break-glass/handler.cjs +127 -12
  9. package/cjs/commands/aws/iam/break-glass/index.cjs +7 -19
  10. package/cjs/commands/aws/iam/break-glass/schema.cjs +21 -12
  11. package/cjs/commands/aws/iam/check-admin/handler.cjs +89 -10
  12. package/cjs/commands/aws/iam/check-admin/index.cjs +7 -17
  13. package/cjs/commands/aws/iam/check-admin/schema.cjs +19 -12
  14. package/cjs/commands/aws/iam/policies/s3-restrictions-deny-non-s3-services.json +20 -0
  15. package/cjs/commands/aws/iam/policies/sts-federation.json +11 -0
  16. package/cjs/commands/aws/iam/policies/user-admins-deny-list.json +175 -0
  17. package/cjs/commands/aws/iam/policies/user-admins-deny-regions-list.json +41 -0
  18. package/cjs/commands/aws/iam/policies/user-admins-self-service-iam.json +56 -0
  19. package/cjs/commands/aws/iam/policies/user-admins-write-list.json +117 -0
  20. package/cjs/commands/aws/iam/remove-admin/handler.cjs +120 -11
  21. package/cjs/commands/aws/iam/remove-admin/index.cjs +7 -18
  22. package/cjs/commands/aws/iam/remove-admin/schema.cjs +22 -12
  23. package/cjs/commands/aws/iam/setup-acl/handler.cjs +227 -14
  24. package/cjs/commands/aws/iam/setup-acl/index.cjs +13 -33
  25. package/cjs/commands/aws/iam/setup-acl/schema.cjs +19 -7
  26. package/cjs/commands/aws/iam/setup-acl/utils.cjs +305 -20
  27. package/cjs/commands/aws/iam/users/handler.cjs +59 -12
  28. package/cjs/commands/aws/iam/users/index.cjs +18 -41
  29. package/cjs/commands/aws/iam/users/schema.cjs +17 -7
  30. package/cjs/commands/aws/iam/users/utils.cjs +454 -30
  31. package/cjs/commands/aws/index.cjs +223 -229
  32. package/cjs/commands/aws/route53/add-record/handler.cjs +264 -18
  33. package/cjs/commands/aws/route53/add-record/index.cjs +26 -57
  34. package/cjs/commands/aws/route53/add-record/schema.cjs +43 -11
  35. package/cjs/commands/aws/route53/add-record/utils.cjs +404 -37
  36. package/cjs/commands/aws/route53/remove-record/handler.cjs +114 -14
  37. package/cjs/commands/aws/route53/remove-record/index.cjs +5 -18
  38. package/cjs/commands/aws/route53/remove-record/schema.cjs +22 -8
  39. package/cjs/commands/aws/schema.cjs +19 -10
  40. package/cjs/commands/aws/ses/send-email/handler.cjs +73 -12
  41. package/cjs/commands/aws/ses/send-email/index.cjs +9 -23
  42. package/cjs/commands/aws/ses/send-email/schema.cjs +24 -7
  43. package/cjs/commands/aws/ses/send-email/utils.cjs +87 -11
  44. package/cjs/commands/aws/ses/smtp-password.cjs +72 -10
  45. package/cjs/commands/aws/utils/exec-aws.cjs +145 -16
  46. package/cjs/commands/aws/utils/resolve-policy-path.cjs +15 -6
  47. package/cjs/commands/aws/utils/resolve-profile.cjs +93 -11
  48. package/cjs/commands/aws/utils/tty.cjs +54 -10
  49. package/cjs/commands/db/create-readonly-user/handler.cjs +254 -11
  50. package/cjs/commands/db/create-readonly-user/index.cjs +18 -40
  51. package/cjs/commands/db/create-readonly-user/mysql.cjs +102 -9
  52. package/cjs/commands/db/create-readonly-user/postgres.cjs +209 -9
  53. package/cjs/commands/db/create-readonly-user/schema.cjs +39 -12
  54. package/cjs/commands/db/create-readonly-user/utils.cjs +160 -22
  55. package/cjs/commands/db/index.cjs +46 -44
  56. package/cjs/commands/doppler/handler.cjs +95 -11
  57. package/cjs/commands/doppler/index.cjs +33 -68
  58. package/cjs/commands/doppler/schema.cjs +130 -14
  59. package/cjs/commands/doppler/set-secret.cjs +378 -19
  60. package/cjs/commands/doppler/utils/exec.cjs +106 -12
  61. package/cjs/commands/doppler/utils.cjs +412 -34
  62. package/cjs/commands/icons/handler.cjs +82 -8
  63. package/cjs/commands/icons/index.cjs +15 -31
  64. package/cjs/commands/icons/schema.cjs +101 -13
  65. package/cjs/commands/icons/utils.cjs +131 -13
  66. package/cjs/commands/index.cjs +54 -161
  67. package/cjs/commands/schema.cjs +25 -8
  68. package/cjs/index.cjs +3 -4
  69. package/esm/commands/aws/ec2/allow-ip/handler.js +258 -12
  70. package/esm/commands/aws/ec2/allow-ip/index.js +4 -55
  71. package/esm/commands/aws/ec2/allow-ip/schema.js +29 -13
  72. package/esm/commands/aws/ec2/allow-ip/utils.js +363 -39
  73. package/esm/commands/aws/iam/admin-group.js +104 -15
  74. package/esm/commands/aws/iam/break-glass/handler.js +124 -12
  75. package/esm/commands/aws/iam/break-glass/index.js +4 -19
  76. package/esm/commands/aws/iam/break-glass/schema.js +19 -12
  77. package/esm/commands/aws/iam/check-admin/handler.js +86 -10
  78. package/esm/commands/aws/iam/check-admin/index.js +4 -17
  79. package/esm/commands/aws/iam/check-admin/schema.js +17 -12
  80. package/esm/commands/aws/iam/policies/s3-restrictions-deny-non-s3-services.json +20 -0
  81. package/esm/commands/aws/iam/policies/sts-federation.json +11 -0
  82. package/esm/commands/aws/iam/policies/user-admins-deny-list.json +175 -0
  83. package/esm/commands/aws/iam/policies/user-admins-deny-regions-list.json +41 -0
  84. package/esm/commands/aws/iam/policies/user-admins-self-service-iam.json +56 -0
  85. package/esm/commands/aws/iam/policies/user-admins-write-list.json +117 -0
  86. package/esm/commands/aws/iam/remove-admin/handler.js +117 -11
  87. package/esm/commands/aws/iam/remove-admin/index.js +4 -18
  88. package/esm/commands/aws/iam/remove-admin/schema.js +20 -12
  89. package/esm/commands/aws/iam/setup-acl/handler.js +224 -14
  90. package/esm/commands/aws/iam/setup-acl/index.js +4 -33
  91. package/esm/commands/aws/iam/setup-acl/schema.js +18 -7
  92. package/esm/commands/aws/iam/setup-acl/utils.js +298 -20
  93. package/esm/commands/aws/iam/users/handler.js +56 -12
  94. package/esm/commands/aws/iam/users/index.js +4 -41
  95. package/esm/commands/aws/iam/users/schema.js +16 -7
  96. package/esm/commands/aws/iam/users/utils.js +440 -30
  97. package/esm/commands/aws/index.js +142 -229
  98. package/esm/commands/aws/route53/add-record/handler.js +258 -18
  99. package/esm/commands/aws/route53/add-record/index.js +4 -57
  100. package/esm/commands/aws/route53/add-record/schema.js +40 -11
  101. package/esm/commands/aws/route53/add-record/utils.js +389 -37
  102. package/esm/commands/aws/route53/remove-record/handler.js +111 -14
  103. package/esm/commands/aws/route53/remove-record/index.js +3 -18
  104. package/esm/commands/aws/route53/remove-record/schema.js +21 -8
  105. package/esm/commands/aws/schema.js +16 -10
  106. package/esm/commands/aws/ses/send-email/handler.js +70 -12
  107. package/esm/commands/aws/ses/send-email/index.js +4 -23
  108. package/esm/commands/aws/ses/send-email/schema.js +23 -7
  109. package/esm/commands/aws/ses/send-email/utils.js +84 -11
  110. package/esm/commands/aws/ses/smtp-password.js +69 -10
  111. package/esm/commands/aws/utils/exec-aws.js +136 -15
  112. package/esm/commands/aws/utils/resolve-policy-path.js +14 -6
  113. package/esm/commands/aws/utils/resolve-profile.js +88 -11
  114. package/esm/commands/aws/utils/tty.js +51 -10
  115. package/esm/commands/db/create-readonly-user/handler.js +251 -11
  116. package/esm/commands/db/create-readonly-user/index.js +4 -40
  117. package/esm/commands/db/create-readonly-user/mysql.js +98 -9
  118. package/esm/commands/db/create-readonly-user/postgres.js +205 -9
  119. package/esm/commands/db/create-readonly-user/schema.js +35 -12
  120. package/esm/commands/db/create-readonly-user/utils.js +151 -22
  121. package/esm/commands/db/index.js +31 -44
  122. package/esm/commands/doppler/handler.js +92 -11
  123. package/esm/commands/doppler/index.js +6 -68
  124. package/esm/commands/doppler/schema.js +125 -15
  125. package/esm/commands/doppler/set-secret.js +370 -19
  126. package/esm/commands/doppler/utils/exec.js +100 -12
  127. package/esm/commands/doppler/utils.js +396 -34
  128. package/esm/commands/icons/handler.js +79 -8
  129. package/esm/commands/icons/index.js +4 -31
  130. package/esm/commands/icons/schema.js +97 -15
  131. package/esm/commands/icons/utils.js +125 -13
  132. package/esm/commands/index.js +47 -155
  133. package/esm/commands/schema.js +22 -7
  134. package/esm/index.js +3 -4
  135. package/package.json +5 -2
  136. package/vitest.config.ts +11 -0
  137. package/cjs/__chunks/2FSYDFUV.cjs +0 -146
  138. package/cjs/__chunks/3A5ZYU5M.cjs +0 -105
  139. package/cjs/__chunks/3BY5Y4W7.cjs +0 -1
  140. package/cjs/__chunks/3NOHGUCF.cjs +0 -9
  141. package/cjs/__chunks/3T2LXW7J.cjs +0 -387
  142. package/cjs/__chunks/4SFWHCB3.cjs +0 -133
  143. package/cjs/__chunks/4XT5JEAS.cjs +0 -1
  144. package/cjs/__chunks/AZEB4H4I.cjs +0 -208
  145. package/cjs/__chunks/B2KFW7T7.cjs +0 -1
  146. package/cjs/__chunks/B5ENMOCD.cjs +0 -288
  147. package/cjs/__chunks/B6XM5KSF.cjs +0 -338
  148. package/cjs/__chunks/BDU2UCE5.cjs +0 -1
  149. package/cjs/__chunks/BLMSMR5E.cjs +0 -46
  150. package/cjs/__chunks/CMUD7LLN.cjs +0 -47
  151. package/cjs/__chunks/DTQ2LB3I.cjs +0 -49
  152. package/cjs/__chunks/FM5MVRQF.cjs +0 -23
  153. package/cjs/__chunks/FRHST54J.cjs +0 -135
  154. package/cjs/__chunks/FU4VP2LN.cjs +0 -1
  155. package/cjs/__chunks/G5K4PVIL.cjs +0 -26
  156. package/cjs/__chunks/GU3R54MK.cjs +0 -127
  157. package/cjs/__chunks/GUL36IFZ.cjs +0 -61
  158. package/cjs/__chunks/GZMTNK5N.cjs +0 -1
  159. package/cjs/__chunks/H74JSDBU.cjs +0 -30
  160. package/cjs/__chunks/INFOPAHN.cjs +0 -117
  161. package/cjs/__chunks/J36P6UNE.cjs +0 -75
  162. package/cjs/__chunks/JB7T7PKQ.cjs +0 -538
  163. package/cjs/__chunks/JSL2JDMW.cjs +0 -1
  164. package/cjs/__chunks/K4QNHRTP.cjs +0 -163
  165. package/cjs/__chunks/KU76LC42.cjs +0 -192
  166. package/cjs/__chunks/LFDSHANP.cjs +0 -34
  167. package/cjs/__chunks/LHE24ECK.cjs +0 -192
  168. package/cjs/__chunks/LIKQ3SI4.cjs +0 -1
  169. package/cjs/__chunks/LXDF5QVZ.cjs +0 -313
  170. package/cjs/__chunks/LXOOJR2R.cjs +0 -74
  171. package/cjs/__chunks/N5MXFOQZ.cjs +0 -167
  172. package/cjs/__chunks/N7D56LPP.cjs +0 -25
  173. package/cjs/__chunks/NFXQNOQH.cjs +0 -393
  174. package/cjs/__chunks/NIMXXHJQ.cjs +0 -92
  175. package/cjs/__chunks/NLKJIUEX.cjs +0 -126
  176. package/cjs/__chunks/NT2XXAI6.cjs +0 -89
  177. package/cjs/__chunks/NWZGFHKH.cjs +0 -121
  178. package/cjs/__chunks/R3GUC7O7.cjs +0 -110
  179. package/cjs/__chunks/RPVAXPJ4.cjs +0 -1
  180. package/cjs/__chunks/S3LVCWPN.cjs +0 -23
  181. package/cjs/__chunks/SBBNW2BF.cjs +0 -249
  182. package/cjs/__chunks/T2A7TN4F.cjs +0 -81
  183. package/cjs/__chunks/TKNNDDIB.cjs +0 -97
  184. package/cjs/__chunks/TNSRDJPR.cjs +0 -1
  185. package/cjs/__chunks/UWHPE2GI.cjs +0 -20
  186. package/cjs/__chunks/W6K7BV74.cjs +0 -1
  187. package/cjs/__chunks/WBOQ6AUN.cjs +0 -320
  188. package/cjs/__chunks/WHGN5PZI.cjs +0 -299
  189. package/cjs/__chunks/WOYF2L6T.cjs +0 -11
  190. package/cjs/__chunks/X26XY2N6.cjs +0 -18
  191. package/cjs/__chunks/XMKOKRXZ.cjs +0 -16
  192. package/cjs/__chunks/XTJPQ3EX.cjs +0 -1
  193. package/cjs/__chunks/YRHFKTW2.cjs +0 -63
  194. package/cjs/__chunks/ZMDIOZPT.cjs +0 -22
  195. package/cjs/commands/aws/iam/policies/s3-restrictions-deny-non-s3-services.cjs +0 -28
  196. package/cjs/commands/aws/iam/policies/sts-federation.cjs +0 -19
  197. package/cjs/commands/aws/iam/policies/user-admins-deny-list.cjs +0 -183
  198. package/cjs/commands/aws/iam/policies/user-admins-deny-regions-list.cjs +0 -49
  199. package/cjs/commands/aws/iam/policies/user-admins-self-service-iam.cjs +0 -64
  200. package/cjs/commands/aws/iam/policies/user-admins-write-list.cjs +0 -125
  201. package/esm/__chunks/2FTTEFEK.js +0 -97
  202. package/esm/__chunks/33UYMUQD.js +0 -338
  203. package/esm/__chunks/3BKWTHLJ.js +0 -25
  204. package/esm/__chunks/3HE4BEJX.js +0 -105
  205. package/esm/__chunks/3QLI5BDL.js +0 -387
  206. package/esm/__chunks/5GIUAFXL.js +0 -89
  207. package/esm/__chunks/5ZBVGSOK.js +0 -0
  208. package/esm/__chunks/6G4PXXKF.js +0 -75
  209. package/esm/__chunks/73BJG53F.js +0 -11
  210. package/esm/__chunks/7VF4Q43Q.js +0 -0
  211. package/esm/__chunks/AEDEAYF5.js +0 -0
  212. package/esm/__chunks/AZCP3SFJ.js +0 -0
  213. package/esm/__chunks/B2DVQ2UL.js +0 -61
  214. package/esm/__chunks/CVQVHLW5.js +0 -0
  215. package/esm/__chunks/D62SPZXC.js +0 -0
  216. package/esm/__chunks/DLEJ25GZ.js +0 -121
  217. package/esm/__chunks/DMYFNF54.js +0 -192
  218. package/esm/__chunks/DNFTUMGD.js +0 -23
  219. package/esm/__chunks/DVKD6YSR.js +0 -49
  220. package/esm/__chunks/EMSH4P76.js +0 -20
  221. package/esm/__chunks/FFKFVMIE.js +0 -167
  222. package/esm/__chunks/FL7AILGH.js +0 -133
  223. package/esm/__chunks/FNXUONAV.js +0 -110
  224. package/esm/__chunks/G4NJHFFU.js +0 -320
  225. package/esm/__chunks/HJSXC6HP.js +0 -117
  226. package/esm/__chunks/IEOGAQYI.js +0 -46
  227. package/esm/__chunks/IZFGBYGE.js +0 -34
  228. package/esm/__chunks/J34UVKLA.js +0 -26
  229. package/esm/__chunks/JZPBBBIG.js +0 -74
  230. package/esm/__chunks/KWUJP5MG.js +0 -135
  231. package/esm/__chunks/M35URMT4.js +0 -313
  232. package/esm/__chunks/NF3M2L6C.js +0 -81
  233. package/esm/__chunks/O3CCA76Q.js +0 -22
  234. package/esm/__chunks/PNPPDYKC.js +0 -299
  235. package/esm/__chunks/QFXN4EHM.js +0 -393
  236. package/esm/__chunks/QKDDLIWD.js +0 -146
  237. package/esm/__chunks/QSE66AKY.js +0 -208
  238. package/esm/__chunks/QUF7PS4R.js +0 -18
  239. package/esm/__chunks/S7IJPJ4R.js +0 -126
  240. package/esm/__chunks/SD3E3EPH.js +0 -163
  241. package/esm/__chunks/SJXQJ7RS.js +0 -92
  242. package/esm/__chunks/SNCKIAOR.js +0 -0
  243. package/esm/__chunks/T3TTUHTW.js +0 -30
  244. package/esm/__chunks/TIOVE6HR.js +0 -0
  245. package/esm/__chunks/TXKMEIDQ.js +0 -0
  246. package/esm/__chunks/U7HAE2RF.js +0 -288
  247. package/esm/__chunks/UXWY7BYE.js +0 -63
  248. package/esm/__chunks/VKAKISRG.js +0 -192
  249. package/esm/__chunks/WD2YR6I7.js +0 -0
  250. package/esm/__chunks/WOZFZKFY.js +0 -0
  251. package/esm/__chunks/XI7GZDE2.js +0 -0
  252. package/esm/__chunks/XOUWDB3T.js +0 -249
  253. package/esm/__chunks/XQN2TA4S.js +0 -23
  254. package/esm/__chunks/XXK32TIM.js +0 -16
  255. package/esm/__chunks/YGWTVPZE.js +0 -538
  256. package/esm/__chunks/YRG7PT33.js +0 -127
  257. package/esm/__chunks/ZHKVJO2U.js +0 -47
  258. package/esm/__chunks/ZO55YUSY.js +0 -9
  259. package/esm/commands/aws/iam/policies/s3-restrictions-deny-non-s3-services.js +0 -28
  260. package/esm/commands/aws/iam/policies/sts-federation.js +0 -19
  261. package/esm/commands/aws/iam/policies/user-admins-deny-list.js +0 -183
  262. package/esm/commands/aws/iam/policies/user-admins-deny-regions-list.js +0 -49
  263. package/esm/commands/aws/iam/policies/user-admins-self-service-iam.js +0 -64
  264. package/esm/commands/aws/iam/policies/user-admins-write-list.js +0 -125
@@ -1,121 +0,0 @@
1
- // src/commands/db/create-readonly-user/utils.js
2
- import { randomBytes } from "crypto";
3
- function generatePassword(params = {}) {
4
- const { length = 24 } = params;
5
- const alphabet = "ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz23456789!@#$%^&*";
6
- const bytes = randomBytes(length);
7
- let result = "";
8
- for (let i = 0; i < length; i += 1) {
9
- const byte = bytes[i] ?? 0;
10
- result += alphabet[byte % alphabet.length];
11
- }
12
- return result;
13
- }
14
- function detectEngineFromUrl(url) {
15
- const trimmed = url.trim().toLowerCase();
16
- if (trimmed.startsWith("postgres://") || trimmed.startsWith("postgresql://")) {
17
- return "postgres";
18
- }
19
- if (trimmed.startsWith("mysql://") || trimmed.startsWith("mysql2://")) {
20
- return "mysql";
21
- }
22
- return null;
23
- }
24
- function resolveAdminUrl(params) {
25
- const { url, engine } = params;
26
- if (url) {
27
- return url;
28
- }
29
- if (engine === "mysql") {
30
- return process.env.MYSQL_URL ?? process.env.DATABASE_URL ?? process.env.MYSQL_DATABASE_URL ?? null;
31
- }
32
- if (engine === "postgres") {
33
- return process.env.DATABASE_URL ?? process.env.POSTGRES_URL ?? process.env.POSTGRESQL_URL ?? null;
34
- }
35
- return process.env.DATABASE_URL ?? process.env.POSTGRES_URL ?? process.env.POSTGRESQL_URL ?? process.env.MYSQL_URL ?? process.env.MYSQL_DATABASE_URL ?? null;
36
- }
37
- function resolveSsl(params) {
38
- const { host, sslOption } = params;
39
- if (sslOption === true) {
40
- return { rejectUnauthorized: false };
41
- }
42
- if (sslOption === false) {
43
- return false;
44
- }
45
- const local = host === "localhost" || host === "127.0.0.1" || host === "::1" || host === "0.0.0.0";
46
- if (local) {
47
- return false;
48
- }
49
- return { rejectUnauthorized: false };
50
- }
51
- function parseConnectionUrl(params) {
52
- const { url, engine: engineOption, sslOption } = params;
53
- const engine = engineOption ?? detectEngineFromUrl(url);
54
- if (!engine) {
55
- throw new Error(
56
- `Could not detect engine from URL. Pass --engine postgres|mysql. URL starts with: ${url.slice(0, 24)}\u2026`
57
- );
58
- }
59
- let parsed;
60
- try {
61
- parsed = new URL(url);
62
- } catch {
63
- throw new Error(`Invalid connection URL: ${url}`);
64
- }
65
- const defaultPort = engine === "postgres" ? 5432 : 3306;
66
- const port = parsed.port ? Number.parseInt(parsed.port, 10) : defaultPort;
67
- const database = decodeURIComponent(parsed.pathname.replace(/^\//, "")) || (engine === "postgres" ? "postgres" : "");
68
- const host = parsed.hostname || "localhost";
69
- const user = decodeURIComponent(parsed.username || "");
70
- const password = decodeURIComponent(parsed.password || "");
71
- if (!user) {
72
- throw new Error("Connection URL is missing a username");
73
- }
74
- return {
75
- engine,
76
- host,
77
- port: Number.isFinite(port) ? port : defaultPort,
78
- user,
79
- password,
80
- database,
81
- ssl: resolveSsl({ host, sslOption }),
82
- url
83
- };
84
- }
85
- function buildReadonlyUrl(params) {
86
- const { engine, host, port, username, password, database } = params;
87
- const scheme = engine === "postgres" ? "postgresql" : "mysql";
88
- const auth = `${encodeURIComponent(username)}:${encodeURIComponent(password)}`;
89
- const dbPath = database ? `/${encodeURIComponent(database)}` : "/";
90
- return `${scheme}://${auth}@${host}:${port}${dbPath}`;
91
- }
92
- function quoteIdent(params) {
93
- const { engine, name } = params;
94
- if (engine === "postgres") {
95
- return `"${name.replace(/"/g, '""')}"`;
96
- }
97
- return `\`${name.replace(/`/g, "``")}\``;
98
- }
99
- function quoteLiteral(value) {
100
- return `'${value.replace(/'/g, "''")}'`;
101
- }
102
- function isSystemDatabase(params) {
103
- const { engine, name } = params;
104
- const lower = name.toLowerCase();
105
- if (engine === "postgres") {
106
- return lower === "template0" || lower === "template1" || lower === "rdsadmin" || lower === "cloudsqladmin";
107
- }
108
- return lower === "information_schema" || lower === "performance_schema" || lower === "mysql" || lower === "sys" || lower === "innodb" || lower === "#mysql50#lost+found";
109
- }
110
-
111
- export {
112
- generatePassword,
113
- detectEngineFromUrl,
114
- resolveAdminUrl,
115
- resolveSsl,
116
- parseConnectionUrl,
117
- buildReadonlyUrl,
118
- quoteIdent,
119
- quoteLiteral,
120
- isSystemDatabase
121
- };
@@ -1,192 +0,0 @@
1
- import {
2
- ACL_GROUPS,
3
- CUSTOM_POLICIES,
4
- attach,
5
- detach,
6
- ensureGroup,
7
- printFinalState,
8
- publishPolicy
9
- } from "./XOUWDB3T.js";
10
- import {
11
- createUsersInteractive
12
- } from "./3QLI5BDL.js";
13
- import {
14
- setupAclOptionsSchema
15
- } from "./XQN2TA4S.js";
16
- import {
17
- getCallerIdentity,
18
- requireCommands
19
- } from "./FNXUONAV.js";
20
- import {
21
- resolveProfile
22
- } from "./5GIUAFXL.js";
23
- import {
24
- promptYesNo
25
- } from "./ZHKVJO2U.js";
26
-
27
- // src/commands/aws/iam/setup-acl/handler.js
28
- import chalk from "chalk";
29
- import { ZodError } from "zod";
30
- async function resolveRestrictRegions(params) {
31
- const { restrictRegions } = params;
32
- if (restrictRegions) {
33
- console.log(`Region restriction: ${restrictRegions}`);
34
- return restrictRegions === "yes";
35
- }
36
- console.log("Region restriction");
37
- console.log(
38
- " The policy UserAdminsDenyRegionsList limits acl-power-users to a hard-coded"
39
- );
40
- console.log(
41
- " region allowlist. Most accounts should leave this OFF unless you have a strong reason."
42
- );
43
- const restrict = await promptYesNo({
44
- message: " Attach region restriction to acl-power-users?",
45
- defaultYes: false
46
- });
47
- console.log(` \u2192 ${restrict ? "yes" : "no"}`);
48
- console.log("");
49
- return restrict;
50
- }
51
- async function setupAclCommand(options) {
52
- try {
53
- const {
54
- restrictRegions,
55
- createUsers,
56
- profile: profileOption,
57
- region,
58
- verbose
59
- } = setupAclOptionsSchema.parse(options);
60
- requireCommands(["aws"]);
61
- const profile = await resolveProfile({ profile: profileOption });
62
- const identity = getCallerIdentity({ profile, region, verbose });
63
- const accountId = identity.Account;
64
- console.log("Caller:");
65
- console.log(` Account: ${accountId}`);
66
- console.log(` Arn: ${identity.Arn}`);
67
- console.log("");
68
- const restrict = await resolveRestrictRegions({ restrictRegions });
69
- console.log("1. Ensure groups exist...");
70
- for (const group of ACL_GROUPS) {
71
- ensureGroup({ name: group, profile, verbose });
72
- }
73
- console.log("");
74
- console.log("2. Publish custom policies...");
75
- for (const policy of CUSTOM_POLICIES) {
76
- publishPolicy({
77
- name: policy.name,
78
- fileName: policy.fileName,
79
- accountId,
80
- profile,
81
- verbose
82
- });
83
- }
84
- console.log("");
85
- const ADMIN = "arn:aws:iam::aws:policy/AdministratorAccess";
86
- const IAM_FULL = "arn:aws:iam::aws:policy/IAMFullAccess";
87
- const READ_ONLY = "arn:aws:iam::aws:policy/ReadOnlyAccess";
88
- const WRITE_LIST = `arn:aws:iam::${accountId}:policy/UserAdminsWriteList`;
89
- const DENY_LIST = `arn:aws:iam::${accountId}:policy/UserAdminsDenyList`;
90
- const SELF_SERVICE = `arn:aws:iam::${accountId}:policy/UserAdminsSelfServiceIAM`;
91
- const DENY_REGIONS = `arn:aws:iam::${accountId}:policy/UserAdminsDenyRegionsList`;
92
- const STS_FEDERATION = `arn:aws:iam::${accountId}:policy/sts-federation`;
93
- const S3_RESTRICTIONS = `arn:aws:iam::${accountId}:policy/S3RestrictionsDenyNonS3Services`;
94
- console.log("3. Attach policies to groups...");
95
- attach({ group: "acl-admin-do-not-use", arn: ADMIN, profile, verbose });
96
- attach({ group: "acl-iam-full-access", arn: IAM_FULL, profile, verbose });
97
- attach({ group: "acl-iam-full-access", arn: READ_ONLY, profile, verbose });
98
- attach({
99
- group: "acl-iam-full-access",
100
- arn: SELF_SERVICE,
101
- profile,
102
- verbose
103
- });
104
- attach({
105
- group: "acl-iam-full-access",
106
- arn: STS_FEDERATION,
107
- profile,
108
- verbose
109
- });
110
- detach({ group: "acl-iam-full-access", arn: DENY_LIST, profile, verbose });
111
- attach({ group: "acl-power-users", arn: READ_ONLY, profile, verbose });
112
- attach({ group: "acl-power-users", arn: WRITE_LIST, profile, verbose });
113
- attach({ group: "acl-power-users", arn: DENY_LIST, profile, verbose });
114
- attach({ group: "acl-power-users", arn: SELF_SERVICE, profile, verbose });
115
- attach({ group: "acl-read-only", arn: READ_ONLY, profile, verbose });
116
- attach({ group: "acl-read-only", arn: STS_FEDERATION, profile, verbose });
117
- attach({
118
- group: "acl-s3-restrictions",
119
- arn: S3_RESTRICTIONS,
120
- profile,
121
- verbose
122
- });
123
- console.log("");
124
- console.log("4. Apply region restriction to acl-power-users...");
125
- if (restrict) {
126
- attach({ group: "acl-power-users", arn: DENY_REGIONS, profile, verbose });
127
- } else {
128
- detach({ group: "acl-power-users", arn: DENY_REGIONS, profile, verbose });
129
- }
130
- console.log("");
131
- console.log("5. Detach legacy policies (if present)...");
132
- const LEGACY_POWER_USER = "arn:aws:iam::aws:policy/PowerUserAccess";
133
- const LEGACY_IAM_RO = "arn:aws:iam::aws:policy/IAMReadOnlyAccess";
134
- const LEGACY_ALLOW = `arn:aws:iam::${accountId}:policy/UserAdminsAllowList`;
135
- const LEGACY_DENY_SVCS = `arn:aws:iam::${accountId}:policy/UserAdminsDenyListServices`;
136
- const LEGACY_DENY_GPU = `arn:aws:iam::${accountId}:policy/UserAdminsDenyListGpu`;
137
- const legacyArns = [
138
- LEGACY_POWER_USER,
139
- LEGACY_IAM_RO,
140
- LEGACY_ALLOW,
141
- LEGACY_DENY_SVCS,
142
- LEGACY_DENY_GPU
143
- ];
144
- for (const group of ACL_GROUPS) {
145
- for (const arn of legacyArns) {
146
- detach({ group, arn, profile, verbose });
147
- }
148
- }
149
- console.log("");
150
- console.log("6. Final state:");
151
- printFinalState({ profile, verbose });
152
- console.log("");
153
- if (createUsers) {
154
- console.log("7. Create IAM users (optional)");
155
- console.log("");
156
- await createUsersInteractive({ profile, verbose });
157
- }
158
- console.log(chalk.green("\n\u2705 ACL setup complete."));
159
- } catch (error) {
160
- if (error instanceof ZodError) {
161
- console.error(chalk.red("\n\u274C Invalid command options:"));
162
- error.errors.forEach((err) => {
163
- console.error(chalk.red(` ${err.path.join(".")}: ${err.message}`));
164
- });
165
- process.exit(1);
166
- }
167
- const verbose = (
168
- /** @type {any} */
169
- options?.verbose || false
170
- );
171
- console.error(chalk.red("\n\u274C iam setup-acl failed:"));
172
- if (error instanceof Error) {
173
- console.error(chalk.red(` ${error.message}`));
174
- if (verbose && error.stack) {
175
- console.error(chalk.gray("\nStack trace:"));
176
- console.error(chalk.gray(error.stack));
177
- }
178
- } else {
179
- console.error(chalk.red(` ${String(error)}`));
180
- }
181
- console.error(
182
- chalk.yellow(
183
- "\n\u{1F4A1} Run with a profile that has IAMFullAccess (e.g. md-*-iam-admin).\n"
184
- )
185
- );
186
- process.exit(1);
187
- }
188
- }
189
-
190
- export {
191
- setupAclCommand
192
- };
@@ -1,23 +0,0 @@
1
- import {
2
- profileField,
3
- verboseField
4
- } from "./73BJG53F.js";
5
-
6
- // src/commands/aws/iam/remove-admin/schema.js
7
- import { z } from "zod";
8
- var removeAdminOptionsSchema = z.object({
9
- profile: profileField,
10
- all: z.boolean().optional().default(false).describe(
11
- "Scan every aws-vault profile (default only when --profile and AWS_PROFILE are unset)"
12
- ),
13
- user: z.array(z.string()).optional().default([]).describe(
14
- "Only remove these user(s); repeatable. Default: every user in the group"
15
- ),
16
- yes: z.boolean().optional().default(false).describe("Skip the per-profile confirmation prompt"),
17
- dryRun: z.boolean().optional().default(false).describe("Preview removals without changing anything"),
18
- verbose: verboseField
19
- });
20
-
21
- export {
22
- removeAdminOptionsSchema
23
- };
@@ -1,49 +0,0 @@
1
- import {
2
- createReadonlyUserCommand
3
- } from "./M35URMT4.js";
4
-
5
- // src/commands/db/index.js
6
- function registerDbCommands(program) {
7
- const db = program.command("db").summary("Database operational commands").description("Database operational helpers (MySQL and Postgres)");
8
- db.command("create-readonly-user").summary("Create a read-only database user").description(
9
- "Create (or update) a read-only database user on MySQL or Postgres. Interactively pick a single database or all databases, then print a connection URL."
10
- ).option(
11
- "-e, --engine <engine>",
12
- "Database engine: postgres or mysql (inferred from --url when omitted)"
13
- ).option(
14
- "-u, --url <url>",
15
- "Admin connection URL (defaults to DATABASE_URL / MYSQL_URL / POSTGRES_URL)"
16
- ).option(
17
- "-d, --database <name>",
18
- 'Target database name, or "all" for every non-system database'
19
- ).option(
20
- "--username <name>",
21
- "Read-only username to create (default: readonly)"
22
- ).option(
23
- "--password <password>",
24
- "Password for the new user (generated when omitted)"
25
- ).option("--host-pattern <pattern>", "MySQL user host pattern (default: %)").option("--ssl", "Force SSL on (loose verify \u2014 useful for RDS)").option("--no-ssl", "Force SSL off").option("-y, --yes", "Skip the confirmation prompt").option("--dry-run", "Print the SQL plan without applying it").option("-v, --verbose", "Enable verbose logging").action(async (options) => {
26
- let ssl;
27
- if (options.ssl === true) {
28
- ssl = true;
29
- } else if (options.noSsl === true) {
30
- ssl = false;
31
- }
32
- await createReadonlyUserCommand({
33
- engine: options.engine,
34
- url: options.url,
35
- database: options.database,
36
- username: options.username,
37
- password: options.password,
38
- hostPattern: options.hostPattern,
39
- ssl,
40
- yes: options.yes ?? false,
41
- dryRun: options.dryRun ?? false,
42
- verbose: options.verbose ?? false
43
- });
44
- });
45
- }
46
-
47
- export {
48
- registerDbCommands
49
- };
@@ -1,20 +0,0 @@
1
- import {
2
- profileField,
3
- verboseField
4
- } from "./73BJG53F.js";
5
-
6
- // src/commands/aws/iam/break-glass/schema.js
7
- import { z } from "zod";
8
- var breakGlassOptionsSchema = z.object({
9
- profile: profileField,
10
- user: z.array(z.string()).optional().default([]).describe(
11
- "Grant break-glass to this user (repeatable). Default: your own IAM user"
12
- ),
13
- yes: z.boolean().optional().default(false).describe("Skip the confirmation prompt"),
14
- dryRun: z.boolean().optional().default(false).describe("Preview the grant without changing anything"),
15
- verbose: verboseField
16
- });
17
-
18
- export {
19
- breakGlassOptionsSchema
20
- };
@@ -1,167 +0,0 @@
1
- import {
2
- removeAdminOptionsSchema
3
- } from "./DNFTUMGD.js";
4
- import {
5
- ADMIN_GROUP_NAME,
6
- resolveAdminScanProfiles,
7
- resolveProfileScan
8
- } from "./NF3M2L6C.js";
9
- import {
10
- requireCommands
11
- } from "./FNXUONAV.js";
12
- import {
13
- promptYesNo
14
- } from "./ZHKVJO2U.js";
15
-
16
- // src/commands/aws/iam/remove-admin/handler.js
17
- import chalk from "chalk";
18
- import { ZodError } from "zod";
19
- async function removeAdminCommand(options) {
20
- try {
21
- const { profile, all, user, yes, dryRun, verbose } = removeAdminOptionsSchema.parse(options);
22
- requireCommands(["aws"]);
23
- const userFilter = new Set(user);
24
- const needsVault = all || !(profile ?? process.env.AWS_PROFILE);
25
- if (needsVault) {
26
- requireCommands(["aws-vault"]);
27
- }
28
- let profiles;
29
- try {
30
- profiles = resolveAdminScanProfiles({ profile, all });
31
- } catch (resolveError) {
32
- if (resolveError instanceof Error && resolveError.message === "No aws-vault profiles with credentials found.") {
33
- console.error(chalk.red(resolveError.message));
34
- process.exit(1);
35
- }
36
- throw resolveError;
37
- }
38
- console.log(
39
- chalk.blue(
40
- `
41
- ==> Removing break-glass access (${ADMIN_GROUP_NAME}) across ${profiles.length} profile(s)
42
- `
43
- )
44
- );
45
- if (dryRun) {
46
- console.log(chalk.yellow("[dry-run] No changes will be made.\n"));
47
- }
48
- let removed = 0;
49
- let cleaned = 0;
50
- let skipped = 0;
51
- for (const candidate of profiles) {
52
- const scan = resolveProfileScan({ profile: candidate, verbose });
53
- if (!scan) {
54
- skipped += 1;
55
- continue;
56
- }
57
- if (scan.users.length === 0) {
58
- if (verbose) {
59
- console.log(
60
- chalk.green(`OK ${candidate} (${scan.accountId}) \u2014 0 users`)
61
- );
62
- }
63
- cleaned += 1;
64
- continue;
65
- }
66
- const targets = userFilter.size > 0 ? scan.users.filter((name) => userFilter.has(name)) : scan.users;
67
- if (targets.length === 0) {
68
- console.log(
69
- chalk.dim(
70
- `-- ${candidate} (${scan.accountId}) \u2014 has users but none match --user`
71
- )
72
- );
73
- skipped += 1;
74
- continue;
75
- }
76
- console.log(
77
- chalk.red(
78
- `FOUND ${candidate} (${scan.accountId}) \u2014 ${targets.length} user(s): ${targets.join(", ")}`
79
- )
80
- );
81
- if (dryRun) {
82
- for (const name of targets) {
83
- console.log(
84
- chalk.yellow(
85
- ` [dry-run] would remove ${name} from ${ADMIN_GROUP_NAME}`
86
- )
87
- );
88
- }
89
- continue;
90
- }
91
- let confirmed = yes;
92
- if (!confirmed) {
93
- confirmed = await promptYesNo({
94
- message: ` Remove ${targets.length} user(s) from ${ADMIN_GROUP_NAME} in ${candidate}?`,
95
- defaultYes: false
96
- });
97
- }
98
- if (!confirmed) {
99
- console.log(chalk.dim(" skipped (not confirmed)"));
100
- skipped += 1;
101
- continue;
102
- }
103
- for (const name of targets) {
104
- try {
105
- scan.run(
106
- [
107
- "iam",
108
- "remove-user-from-group",
109
- "--group-name",
110
- ADMIN_GROUP_NAME,
111
- "--user-name",
112
- name
113
- ],
114
- { expectJson: false }
115
- );
116
- console.log(chalk.green(` removed ${name}`));
117
- removed += 1;
118
- } catch (removeError) {
119
- const reason = removeError instanceof Error ? removeError.message.split("\n")[0] ?? "" : String(removeError);
120
- console.log(chalk.red(` failed to remove ${name}: ${reason}`));
121
- }
122
- }
123
- }
124
- console.log(chalk.blue("\n==> Summary"));
125
- console.log(` Profiles scanned: ${profiles.length}`);
126
- console.log(` Users removed: ${removed}`);
127
- console.log(` Already clean: ${cleaned}`);
128
- console.log(` Skipped: ${skipped}`);
129
- if (dryRun) {
130
- console.log(
131
- chalk.yellow("\n[dry-run] Re-run without --dry-run to apply changes.")
132
- );
133
- }
134
- } catch (error) {
135
- if (error instanceof ZodError) {
136
- console.error(chalk.red("\n\u274C Invalid command options:"));
137
- error.errors.forEach((err) => {
138
- console.error(chalk.red(` ${err.path.join(".")}: ${err.message}`));
139
- });
140
- process.exit(1);
141
- }
142
- const verbose = (
143
- /** @type {any} */
144
- options?.verbose || false
145
- );
146
- console.error(chalk.red("\n\u274C remove-admin failed:"));
147
- if (error instanceof Error) {
148
- console.error(chalk.red(` ${error.message}`));
149
- if (verbose && error.stack) {
150
- console.error(chalk.gray("\nStack trace:"));
151
- console.error(chalk.gray(error.stack));
152
- }
153
- } else {
154
- console.error(chalk.red(` ${String(error)}`));
155
- }
156
- console.error(
157
- chalk.yellow(
158
- "\n\u{1F4A1} Requires the AWS CLI (and aws-vault when scanning multiple profiles) and iam:RemoveUserFromGroup.\n"
159
- )
160
- );
161
- process.exit(1);
162
- }
163
- }
164
-
165
- export {
166
- removeAdminCommand
167
- };