@p0security/cli 0.22.0 → 0.22.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.
- package/CONTRIBUTING.md +1 -1
- package/README.md +21 -0
- package/build/dist/commands/ls.js +17 -2
- package/build/dist/commands/ls.js.map +1 -1
- package/build/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
package/CONTRIBUTING.md
CHANGED
|
@@ -25,6 +25,6 @@ follow certain guidelines, in order to ensure usability of the CLI:
|
|
|
25
25
|
## Single-Artifact Binary
|
|
26
26
|
|
|
27
27
|
To build the CLI as a single-artifact binary, use the `yarn build:macos` script and then
|
|
28
|
-
run `build.sh`. You must have NodeJS version 22 or newer currently installed on your system
|
|
28
|
+
run `build-macOS.sh`. You must have NodeJS version 22 or newer currently installed on your system
|
|
29
29
|
when building the standalone CLI. The resulting binary will be output to `/build/sea`, and can
|
|
30
30
|
be run even if NodeJS is uninstalled on your system. Currently only MacOS is supported.
|
package/README.md
CHANGED
|
@@ -209,6 +209,27 @@ p0 ssh <INSTANCE_NAME>
|
|
|
209
209
|
|
|
210
210
|
If you already have access, this will directly open the SSH session. Otherwise, it will request access, wait for approval, and open a SSH session once the access is provisioned.
|
|
211
211
|
|
|
212
|
+
## macOS URL Handler
|
|
213
|
+
|
|
214
|
+
The P0 CLI includes a macOS URL handler application that registers the `p0://` URL scheme, enabling browser-initiated CLI commands. This allows you to create clickable links that automatically invoke P0 commands.
|
|
215
|
+
|
|
216
|
+
### Example
|
|
217
|
+
|
|
218
|
+
Click a link like `p0://ssh/my-host` in your browser, and it will automatically execute:
|
|
219
|
+
|
|
220
|
+
```bash
|
|
221
|
+
p0 ssh my-host
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
### Installation
|
|
225
|
+
|
|
226
|
+
See [mac/url-handler/README.md](mac/url-handler/README.md) for complete documentation, including:
|
|
227
|
+
|
|
228
|
+
- Building and installing the URL handler
|
|
229
|
+
- URL format reference
|
|
230
|
+
- Integration examples
|
|
231
|
+
- Troubleshooting guide
|
|
232
|
+
|
|
212
233
|
## Support
|
|
213
234
|
|
|
214
235
|
If you encounter any issues with the P0 CLI, you can open a GitHub issue on this repo, email `support@p0.dev`, or reach out to us on our [community slack](https://join.slack.com/t/p0securitycommunity/shared_invite/zt-1zouzlovp-1kuym9RfuzkJ17ZlvAf6mQ).
|
|
@@ -31,6 +31,14 @@ const util_1 = require("../util");
|
|
|
31
31
|
const lodash_1 = require("lodash");
|
|
32
32
|
const pluralize_1 = __importDefault(require("pluralize"));
|
|
33
33
|
const DEFAULT_RESPONSE_SIZE = 15;
|
|
34
|
+
/** Extract an argument value from list of arguments.
|
|
35
|
+
* These are parsed by yargs with "unknown-options-as-args" enabled. Each item in the array is a string representing an argument or option.
|
|
36
|
+
* Quoted arguments preserve spaces within them as part of the string. The quotes themselves are also preserved.
|
|
37
|
+
*/
|
|
38
|
+
const argValue = (args, argName) => {
|
|
39
|
+
const index = args.indexOf(`--${argName}`);
|
|
40
|
+
return index !== -1 && index + 1 < args.length ? args[index + 1] : undefined;
|
|
41
|
+
};
|
|
34
42
|
const lsArgs = (yargs) => yargs
|
|
35
43
|
.parserConfiguration({ "unknown-options-as-args": true })
|
|
36
44
|
.help(false)
|
|
@@ -57,7 +65,10 @@ const lsCommand = (yargs) => yargs.command("ls [arguments..]", "List request-com
|
|
|
57
65
|
exports.lsCommand = lsCommand;
|
|
58
66
|
const ls = (args) => __awaiter(void 0, void 0, void 0, function* () {
|
|
59
67
|
const authn = yield (0, auth_1.authenticate)();
|
|
60
|
-
|
|
68
|
+
// yargs parses all unknown options into the "arguments" array. Proper option parsing is done in the backend.
|
|
69
|
+
const principal = argValue(args.arguments, "principal");
|
|
70
|
+
const isAll = args.arguments.includes("--all");
|
|
71
|
+
const isAdminCommand = isAll || principal;
|
|
61
72
|
const command = isAdminCommand ? api_1.fetchAdminLsCommand : api_1.fetchCommand;
|
|
62
73
|
const allArguments = [
|
|
63
74
|
...args._,
|
|
@@ -91,7 +102,11 @@ const ls = (args) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
91
102
|
: data.isTruncated
|
|
92
103
|
? ` (use \`${(0, util_1.getAppName)()} ${allArguments.join(" ")} <like>\` to narrow results)`
|
|
93
104
|
: "";
|
|
94
|
-
|
|
105
|
+
const accessibleTo = principal !== null && principal !== void 0 ? principal : "you";
|
|
106
|
+
const accessiblePart = isAll
|
|
107
|
+
? "" // do not show who they are accessible to because we are displaying all items
|
|
108
|
+
: `\nResources labeled with * are already accessible to ${accessibleTo}:`;
|
|
109
|
+
(0, stdio_1.print2)(`Showing${truncationPart} ${label}${postfixPart}.${accessiblePart}`);
|
|
95
110
|
const truncated = (0, lodash_1.slice)(data.items, 0, args.size);
|
|
96
111
|
const sortedItems = (0, lodash_1.orderBy)(truncated, "isPreexisting", "desc");
|
|
97
112
|
const isSameValue = sortedItems.every((i) => !i.group && i.key === i.value);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ls.js","sourceRoot":"","sources":["../../../src/commands/ls.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;;GASG;AACH,0CAA0C;AAC1C,wCAAmE;AACnE,0CAA+C;AAC/C,4CAA6D;AAC7D,kCAAqC;AACrC,mCAA6C;AAC7C,0DAAkC;AAGlC,MAAM,qBAAqB,GAAG,EAAE,CAAC;AAejC,MAAM,MAAM,GAAG,CAAI,KAAoB,EAAE,EAAE,CACzC,KAAK;KACF,mBAAmB,CAAC,EAAE,yBAAyB,EAAE,IAAI,EAAE,CAAC;KACxD,IAAI,CAAC,KAAK,CAAC;KACX,MAAM,CAAC,WAAW,EAAE;IACnB,KAAK,EAAE,IAAI;IACX,MAAM,EAAE,IAAI;IACZ,OAAO,EAAE,EAAc;CACxB,CAAC;KACD,MAAM,CAAC,MAAM,EAAE;IACd,IAAI,EAAE,QAAQ;IACd,OAAO,EAAE,qBAAqB;IAC9B,WAAW,EAAE,6BAA6B;CAC3C,CAA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