@p0security/cli 0.11.1 → 0.11.2

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 (37) hide show
  1. package/dist/commands/__tests__/login.test.js +17 -0
  2. package/dist/commands/__tests__/login.test.js.map +1 -1
  3. package/dist/commands/__tests__/ls.test.js +4 -3
  4. package/dist/commands/__tests__/ls.test.js.map +1 -1
  5. package/dist/commands/__tests__/ssh.test.js +10 -5
  6. package/dist/commands/__tests__/ssh.test.js.map +1 -1
  7. package/dist/commands/kubeconfig.js +3 -2
  8. package/dist/commands/kubeconfig.js.map +1 -1
  9. package/dist/commands/login.js +11 -0
  10. package/dist/commands/login.js.map +1 -1
  11. package/dist/commands/ls.js +4 -6
  12. package/dist/commands/ls.js.map +1 -1
  13. package/dist/commands/shared/request.js +2 -2
  14. package/dist/commands/shared/request.js.map +1 -1
  15. package/dist/drivers/__mocks__/stdio.d.ts +14 -0
  16. package/dist/drivers/__mocks__/stdio.js +26 -0
  17. package/dist/drivers/__mocks__/stdio.js.map +1 -0
  18. package/dist/drivers/ansi.d.ts +8 -0
  19. package/dist/drivers/ansi.js +25 -0
  20. package/dist/drivers/ansi.js.map +1 -0
  21. package/dist/drivers/auth.d.ts +1 -0
  22. package/dist/drivers/auth.js +8 -4
  23. package/dist/drivers/auth.js.map +1 -1
  24. package/dist/drivers/stdio.d.ts +6 -5
  25. package/dist/drivers/stdio.js +50 -7
  26. package/dist/drivers/stdio.js.map +1 -1
  27. package/dist/plugins/aws/ssh.js +45 -23
  28. package/dist/plugins/aws/ssh.js.map +1 -1
  29. package/dist/plugins/aws/types.d.ts +6 -4
  30. package/dist/plugins/google/ssh-key.js +9 -1
  31. package/dist/plugins/google/ssh-key.js.map +1 -1
  32. package/dist/plugins/google/ssh.js +61 -28
  33. package/dist/plugins/google/ssh.js.map +1 -1
  34. package/dist/plugins/ssh/index.js +62 -88
  35. package/dist/plugins/ssh/index.js.map +1 -1
  36. package/dist/types/ssh.d.ts +28 -13
  37. package/package.json +3 -3
@@ -21,19 +21,18 @@ export type CliPermissionSpec<P extends PluginSshRequest, C extends object | und
21
21
  export declare const SupportedSshProviders: readonly ["aws", "gcloud"];
22
22
  export type SupportedSshProvider = (typeof SupportedSshProviders)[number];
23
23
  export type SshProvider<PR extends PluginSshRequest = PluginSshRequest, O extends object | undefined = undefined, SR extends SshRequest = SshRequest, C extends object | undefined = undefined> = {
24
- requestToSsh: (request: CliPermissionSpec<PR, O>) => SR;
25
- /** Converts a backend request to a CLI request */
26
- toCliRequest: (request: Request<PR>, options?: {
27
- debug?: boolean;
28
- }) => Promise<Request<CliSshRequest>>;
29
- ensureInstall: () => Promise<void>;
30
24
  /** Logs in the user to the cloud provider */
31
25
  cloudProviderLogin: (authn: Authn, request: SR) => Promise<C>;
32
- /** Returns the command and its arguments that are going to be injected as the ssh ProxyCommand option */
33
- proxyCommand: (request: SR) => string[];
34
- /** Each element in the returned array is a command that can be run to reproduce the
35
- * steps of logging in the user to the ssh session. */
36
- reproCommands: (request: SR) => string[] | undefined;
26
+ /** Callback to ensure that this provider's CLI utils are installed */
27
+ ensureInstall: () => Promise<void>;
28
+ /** A human-readable name for this CSP */
29
+ friendlyName: string;
30
+ /** Friendly message to ask the user to log in to the CSP */
31
+ loginRequiredMessage?: string;
32
+ /** Regex match for error string indicating that CSP login is required */
33
+ loginRequiredPattern?: RegExp;
34
+ /** Amount of time, in ms, to wait between granting access and giving up on attempting an SSH connection */
35
+ propagationTimeoutMs: number;
37
36
  /** Arguments for a pre-test command to verify access propagation prior
38
37
  * to actually logging in the user to the ssh session.
39
38
  * This must return arguments for a non-interactive command - meaning the `command`
@@ -42,7 +41,23 @@ export type SshProvider<PR extends PluginSshRequest = PluginSshRequest, O extend
42
41
  * the actual ssh/scp command.
43
42
  */
44
43
  preTestAccessPropagationArgs: (cmdArgs: CommandArgs) => CommandArgs | undefined;
45
- maxRetries: number;
46
- friendlyName: string;
44
+ /** Returns the command and its arguments that are going to be injected as the ssh ProxyCommand option */
45
+ proxyCommand: (request: SR) => string[];
46
+ /** Each element in the returned array is a command that can be run to reproduce the
47
+ * steps of logging in the user to the ssh session. */
48
+ reproCommands: (request: SR) => string[] | undefined;
49
+ /** Unwraps this provider's types */
50
+ requestToSsh: (request: CliPermissionSpec<PR, O>) => SR;
51
+ /** Regex matches for error strings indicating that the provider has not yet fully provisioned node acces */
52
+ unprovisionedAccessPatterns: readonly {
53
+ /** If the error matches this string, indicates that access is not provisioned */
54
+ readonly pattern: RegExp;
55
+ /** Maximum amount of time to wait for provisioning after encountering this error */
56
+ readonly validationWindowMs?: number;
57
+ }[];
58
+ /** Converts a backend request to a CLI request */
59
+ toCliRequest: (request: Request<PR>, options?: {
60
+ debug?: boolean;
61
+ }) => Promise<Request<CliSshRequest>>;
47
62
  };
48
63
  export type SshRequest = AwsSshRequest | GcpSshRequest;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@p0security/cli",
3
- "version": "0.11.1",
3
+ "version": "0.11.2",
4
4
  "description": "Execute infra CLI commands with P0 grants",
5
5
  "main": "index.ts",
6
6
  "repository": {
@@ -65,8 +65,8 @@
65
65
  "eslint-plugin-promise": "^6.1.1",
66
66
  "jest": "^29.7.0",
67
67
  "prettier": "^3.2.4",
68
- "ts-node": "^10.9.2",
69
- "ts-jest": "^29.1.2"
68
+ "ts-jest": "^29.1.2",
69
+ "ts-node": "^10.9.2"
70
70
  },
71
71
  "scripts": {
72
72
  "build": "tsc && cp -r public dist/",