netriskscan-cli 1.6.2 → 2.1.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/CHANGELOG.md +34 -0
- package/README.md +157 -229
- package/dist/cli.js +1351 -443
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +8 -12
- package/dist/index.js +44 -11
- package/dist/index.js.map +1 -1
- package/package.json +6 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,37 @@
|
|
|
1
|
+
# [2.1.0](https://github.com/TeamQQ/netriskscan-cli/compare/v2.0.0...v2.1.0) (2026-12-02)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* **cli:** complete Google sign-in and resume authenticated queries ([f32bbbb](https://github.com/TeamQQ/netriskscan-cli/commit/f32bbbbb1e23a5e7db664115b1e3ab2eb133c0ac))
|
|
7
|
+
|
|
8
|
+
## Google authorization
|
|
9
|
+
|
|
10
|
+
- Start the official Google authorization flow when a terminal query needs a key.
|
|
11
|
+
- Save the exchanged key in the OS credential store and resume the original request.
|
|
12
|
+
- Add `auth login`, `auth key`, and monthly usage details in `auth status`.
|
|
13
|
+
|
|
14
|
+
# [2.0.0](https://github.com/TeamQQ/netriskscan-cli/compare/v1.6.2...v2.0.0) (2026-12-02)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Features
|
|
18
|
+
|
|
19
|
+
* **cli:** require API keys and add credential and quota commands ([f68ca07](https://github.com/TeamQQ/netriskscan-cli/commit/f68ca074e9fe0cdfa180ff51fbf75a4b74f4a4e2))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### BREAKING CHANGES
|
|
23
|
+
|
|
24
|
+
* **cli:** CLI lookups require a Developer API key. Set NETRISKSCAN_API_KEY in automation or save an existing key in the OS credential store.
|
|
25
|
+
|
|
26
|
+
## CLI authentication and quota migration
|
|
27
|
+
|
|
28
|
+
- CLI queries now use authenticated Developer API access and retain success payloads and numeric exit codes.
|
|
29
|
+
- Add OS credential storage with `auth save`, `auth show`, `auth status`, and `auth logout`.
|
|
30
|
+
- Add `quota` as an alias for `usage`, quota warnings, and actionable quota exhaustion errors.
|
|
31
|
+
- Add `upgrade` and `billing` browser entry points. Automatic Google credential delivery and
|
|
32
|
+
Stripe payment verification require backend CLI endpoints.
|
|
33
|
+
- Set `NETRISKSCAN_API_KEY` in CI before moving from 1.x to 2.x.
|
|
34
|
+
|
|
1
35
|
## [1.6.2](https://github.com/TeamQQ/netriskscan-cli/compare/v1.6.1...v1.6.2) (2026-11-28)
|
|
2
36
|
|
|
3
37
|
|
package/README.md
CHANGED
|
@@ -27,19 +27,17 @@ Use the CLI for investigations and operational tasks. Use the TypeScript client
|
|
|
27
27
|
|
|
28
28
|
## Quick start
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
**Developer API requires a valid API Key.**
|
|
31
31
|
|
|
32
32
|
```bash
|
|
33
|
-
npx netriskscan-cli check
|
|
33
|
+
npx netriskscan-cli check 8.8.8.8
|
|
34
34
|
```
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
<img src="https://raw.githubusercontent.com/TeamQQ/netriskscan-cli/main/demo/netriskscan-demo.gif" alt="Live terminal demonstration of netriskscan-cli checking an IP and displaying its NetRiskScan Index, network details, location, and risk signals" width="700" />
|
|
42
|
-
</p>
|
|
36
|
+
With no configured key in an interactive terminal, the CLI opens NetRiskScan's Google
|
|
37
|
+
authorization page. Click **Continue with Google**, enter the eight-character confirmation
|
|
38
|
+
code shown in the terminal, and approve the installation. NetRiskScan sets up a developer
|
|
39
|
+
account when needed and issues the API key. The CLI saves the key in the OS credential
|
|
40
|
+
store and continues your original query. With a configured key the lookup runs immediately.
|
|
43
41
|
|
|
44
42
|
## Product overview
|
|
45
43
|
|
|
@@ -65,14 +63,14 @@ NetRiskScan provides diagnostic network intelligence, not a complete fraud engin
|
|
|
65
63
|
|
|
66
64
|
The Developer API provides a normalized assessment and supporting network context:
|
|
67
65
|
|
|
68
|
-
| Data
|
|
69
|
-
|
|
|
70
|
-
| **NetRiskScan Index & band** | A normalized IP cleanliness assessment. Higher is cleaner.
|
|
71
|
-
| **Independent signals**
|
|
72
|
-
| **Network attribution**
|
|
73
|
-
| **IP geolocation**
|
|
74
|
-
| **Verified identity**
|
|
75
|
-
| **Risk reasons**
|
|
66
|
+
| Data | What it provides |
|
|
67
|
+
| ---------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
|
|
68
|
+
| **NetRiskScan Index & band** | A normalized IP cleanliness assessment. Higher is cleaner. |
|
|
69
|
+
| **Independent signals** | Proxy, VPN, Tor, datacenter, scanner, and abuse flags. Each signal preserves `true`, `false`, or `null` (unknown). |
|
|
70
|
+
| **Network attribution** | Network type, profile, service, ASN, organization, operator domain, and containing CIDR range when resolved. |
|
|
71
|
+
| **IP geolocation** | Network-level country, region, city, continent, postal code, approximate coordinates, and time zone when available. |
|
|
72
|
+
| **Verified identity** | Known search-crawler identity, such as Googlebot, Bingbot, or Applebot, when verified by the API. |
|
|
73
|
+
| **Risk reasons** | Server-generated reason codes with category and severity. Reasons can describe positive infrastructure evidence as well as risk signals. |
|
|
76
74
|
|
|
77
75
|
Fields are returned only when the API can resolve them. Unknown or unavailable values are not silently converted into negative signals.
|
|
78
76
|
|
|
@@ -97,58 +95,58 @@ The installed executable is `netriskscan`; the npm package name is `netriskscan-
|
|
|
97
95
|
|
|
98
96
|
## Access model
|
|
99
97
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
| **Anonymous evaluation** | First lookups and quick CLI tests | `check` and `batch` can run without an API key. Requests are metered by the caller's public IP and subject to a daily allowance. |
|
|
105
|
-
| **Developer API key** | Application integration and account-level usage | Key-authenticated requests use the Developer Account's plan quota. The `usage` command requires a key. |
|
|
106
|
-
| **Paid plan** | Sustained production traffic and higher-volume workloads | Select a plan based on required quota, request rate, and concurrency. Current limits and pricing are shown in the Developer Dashboard. |
|
|
107
|
-
|
|
108
|
-
A Developer account includes a Free Plan for evaluation. For production workloads, use a plan that matches your expected traffic and operational requirements. Plan allowances, rate limits, and concurrency can change; the Developer Dashboard is the source of truth.
|
|
109
|
-
|
|
110
|
-
[Explore Developer API access and plans](https://www.netriskscan.com/pricing.html).
|
|
98
|
+
The CLI resolves credentials in this order: `--api-key`, `NETRISKSCAN_API_KEY`,
|
|
99
|
+
then the OS credential store. CLI lookups send `Authorization: Bearer <API_KEY>`.
|
|
100
|
+
A rejected key returns an authentication error. The Free plan and paid plans use
|
|
101
|
+
account-level quota.
|
|
111
102
|
|
|
112
|
-
|
|
103
|
+
### Migrating from 1.x
|
|
113
104
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
Use an API key when you need account-level quota, sustained usage, or billing-period usage reporting. Anonymous trial exhaustion returns `429 anonymous_daily_limit_reached`; this deterministic response is not automatically retried.
|
|
119
|
-
|
|
120
|
-
| Command | API key |
|
|
121
|
-
| --- | --- |
|
|
122
|
-
| `netriskscan check` | Optional — anonymous trial is used when omitted |
|
|
123
|
-
| `netriskscan batch` | Optional — anonymous trial is used when omitted |
|
|
124
|
-
| `netriskscan usage` | Required — retrieves Developer Account plan and billing-period usage |
|
|
125
|
-
|
|
126
|
-
A configured but invalid or disabled key is never silently downgraded to anonymous access.
|
|
105
|
+
Version 2 requires a key for all CLI lookups. Set `NETRISKSCAN_API_KEY` in CI/CD.
|
|
106
|
+
Interactive Google sign-in can save a key locally. Existing authenticated scripts use
|
|
107
|
+
the same query commands, success payloads, and numeric exit codes. Read `error.code`
|
|
108
|
+
to distinguish failures that share an exit code.
|
|
127
109
|
|
|
128
110
|
## Getting an API key
|
|
129
111
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
1. Create a [NetRiskScan Developer account](https://www.netriskscan.com/developer/register) and open the Developer Dashboard.
|
|
133
|
-
2. Go to **API Keys** and create a key with the scopes required by your integration:
|
|
134
|
-
- `ip-risk:read` — IP risk and network intelligence lookups.
|
|
135
|
-
- `usage:read` — account usage reporting.
|
|
136
|
-
3. Copy the full key when it is created. It is shown in full only once.
|
|
137
|
-
|
|
138
|
-
Set the key as an environment variable instead of putting it directly in a command, source file, or shell history:
|
|
112
|
+
To authorize the CLI before running a query, run:
|
|
139
113
|
|
|
140
114
|
```bash
|
|
141
|
-
|
|
115
|
+
npx netriskscan-cli auth login
|
|
142
116
|
```
|
|
143
117
|
|
|
144
|
-
|
|
118
|
+
If the system browser cannot open, the CLI prints the authorization link and
|
|
119
|
+
confirmation code. Open the link in a browser on any device and keep the terminal
|
|
120
|
+
running. The terminal waits up to ten minutes. Press Ctrl+C to cancel.
|
|
121
|
+
|
|
122
|
+
For a key you already manage in the [Developer Console](https://www.netriskscan.com/developer/keys),
|
|
123
|
+
use `ip-risk:read` for `check` and `batch` and `usage:read` for quota and plan
|
|
124
|
+
reads. Load the key from your secret manager into `NETRISKSCAN_API_KEY`.
|
|
145
125
|
|
|
146
126
|
```bash
|
|
147
|
-
netriskscan
|
|
148
|
-
netriskscan
|
|
127
|
+
npx netriskscan-cli auth save
|
|
128
|
+
npx netriskscan-cli check 8.8.8.8
|
|
149
129
|
```
|
|
150
130
|
|
|
151
|
-
|
|
131
|
+
You can also pipe a key from a secret manager into `npx netriskscan-cli auth save --stdin`.
|
|
132
|
+
The CLI saves it in Windows Credential Manager, macOS Keychain, or Linux Secret Service.
|
|
133
|
+
If the store is unavailable, supply `NETRISKSCAN_API_KEY` from your secret manager for
|
|
134
|
+
each invocation. `auth save` sets the variable within its own process.
|
|
135
|
+
|
|
136
|
+
| Command | What it does |
|
|
137
|
+
| --------------------------------- | ------------------------------------------------------------------------------------------- |
|
|
138
|
+
| `npx netriskscan-cli auth key` | Reveals the stored key in an interactive terminal. `auth show` is also supported. |
|
|
139
|
+
| `npx netriskscan-cli auth status` | Verifies the selected key and shows its masked value, storage, plan, and monthly usage. |
|
|
140
|
+
| `npx netriskscan-cli auth logout` | Removes the local credential. Server-side revocation is available in the Developer Console. |
|
|
141
|
+
|
|
142
|
+
The CLI displays the newly saved key once after authorization. Treat it as a sensitive
|
|
143
|
+
credential. View your Google email and key name in the Developer Console.
|
|
144
|
+
|
|
145
|
+
The [Developer API authorization contract](https://www.netriskscan.com/assets/paid-api-v1.yaml)
|
|
146
|
+
uses browser confirmation, PKCE-protected polling, and RSA-encrypted key delivery.
|
|
147
|
+
The OS credential store holds the key and any pending delivery proof. If you remove
|
|
148
|
+
the local key while the installation's server key is still active, revoke that key
|
|
149
|
+
in the Developer Console before authorizing a replacement.
|
|
152
150
|
|
|
153
151
|
## CLI and TypeScript integration
|
|
154
152
|
|
|
@@ -187,11 +185,11 @@ The SDK preserves the API's response semantics, including nullable signals and o
|
|
|
187
185
|
- [Intelligence returned](#intelligence-returned)
|
|
188
186
|
- [Installation](#installation)
|
|
189
187
|
- [Access model](#access-model)
|
|
190
|
-
- [Anonymous trial](#anonymous-trial)
|
|
191
188
|
- [Getting an API key](#getting-an-api-key)
|
|
192
189
|
- [CLI and TypeScript integration](#cli-and-typescript-integration)
|
|
193
190
|
- [IP risk check](#ip-risk-check)
|
|
194
191
|
- [Usage & quota](#usage--quota)
|
|
192
|
+
- [Upgrade & billing](#upgrade--billing)
|
|
195
193
|
- [Batch processing](#batch-processing)
|
|
196
194
|
- [JSON output](#json-output)
|
|
197
195
|
- [JSONL output](#jsonl-output)
|
|
@@ -214,8 +212,7 @@ The SDK preserves the API's response semantics, including nullable signals and o
|
|
|
214
212
|
netriskscan check <ip> [options]
|
|
215
213
|
```
|
|
216
214
|
|
|
217
|
-
Calls
|
|
218
|
-
optional; without one the request uses the [anonymous trial](#anonymous-trial).
|
|
215
|
+
Calls GET /v1/ip-risk/{ip} with a Developer API key that has the ip-risk:read scope.
|
|
219
216
|
|
|
220
217
|
Supports **IP Intelligence Schema 1.6.0**: `network.domain` / `network.range` and the
|
|
221
218
|
extended `location` fields (continent, postal code, approximate coordinates). The
|
|
@@ -431,55 +428,49 @@ you opt into CI policy checks with `--fail-below` (see [CI/CD](#cicd)).
|
|
|
431
428
|
|
|
432
429
|
### Options
|
|
433
430
|
|
|
434
|
-
| Option | Description
|
|
435
|
-
| ---------------------- |
|
|
436
|
-
| `--api-key <key>` | API key for this call,
|
|
437
|
-
| `--base-url <url>` | Override the API base URL (advanced)
|
|
438
|
-
| `--json` | Machine-readable JSON output (see [JSON output](#json-output))
|
|
439
|
-
| `--verbose` | Also print rate limit, quota, and request id
|
|
440
|
-
| `--debug` | Print a stack trace / extra detail on failure
|
|
441
|
-
| `--timeout <ms>` | Request timeout in milliseconds (default `10000`)
|
|
442
|
-
| `--max-retries <n>` | Max automatic retries for `429`/`503` (default `3`)
|
|
443
|
-
| `--fail-below <index>` | CI gate: exit non-zero if `risk.index` is below this threshold
|
|
444
|
-
| `--fail-on <flag>` | CI gate: exit non-zero if the given flag is `true` (repeatable)
|
|
431
|
+
| Option | Description |
|
|
432
|
+
| ---------------------- | ------------------------------------------------------------------------ |
|
|
433
|
+
| `--api-key <key>` | API key for this call, overrides the environment and OS credential store |
|
|
434
|
+
| `--base-url <url>` | Override the API base URL (advanced) |
|
|
435
|
+
| `--json` | Machine-readable JSON output (see [JSON output](#json-output)) |
|
|
436
|
+
| `--verbose` | Also print rate limit, quota, and request id |
|
|
437
|
+
| `--debug` | Print a stack trace / extra detail on failure |
|
|
438
|
+
| `--timeout <ms>` | Request timeout in milliseconds (default `10000`) |
|
|
439
|
+
| `--max-retries <n>` | Max automatic retries for `429`/`503` (default `3`) |
|
|
440
|
+
| `--fail-below <index>` | CI gate: exit non-zero if `risk.index` is below this threshold |
|
|
441
|
+
| `--fail-on <flag>` | CI gate: exit non-zero if the given flag is `true` (repeatable) |
|
|
445
442
|
|
|
446
443
|
## Usage & quota
|
|
447
444
|
|
|
448
445
|
```bash
|
|
449
|
-
netriskscan usage
|
|
446
|
+
npx netriskscan-cli usage
|
|
447
|
+
npx netriskscan-cli quota
|
|
450
448
|
```
|
|
451
449
|
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
450
|
+
Both commands call `GET /v1/usage` with a key that has `usage:read`. They show the
|
|
451
|
+
current plan, monthly limit, used and remaining units, percentage used, period
|
|
452
|
+
start and reset time, and requests per minute. View subscription status and batch
|
|
453
|
+
entitlement in the [Developer Console](https://www.netriskscan.com/developer/billing).
|
|
455
454
|
|
|
456
|
-
|
|
457
|
-
|
|
455
|
+
Human lookup output warns at 80% and 95% using the lookup's quota headers. The CLI
|
|
456
|
+
suppresses repeats by key, reported limit, and threshold. It rearms warnings when it
|
|
457
|
+
observes usage below the threshold or learns a new quota period from `usage`.
|
|
458
|
+
At exhaustion the CLI displays quota details, reset time when available, and an
|
|
459
|
+
upgrade link. `check --json` includes these details in the error object.
|
|
458
460
|
|
|
459
|
-
|
|
460
|
-
```
|
|
461
|
+
## Upgrade & billing
|
|
461
462
|
|
|
462
463
|
```bash
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
NetRiskScan Usage
|
|
466
|
-
|
|
467
|
-
Plan growth
|
|
468
|
-
|
|
469
|
-
Usage
|
|
470
|
-
Used 12,450
|
|
471
|
-
Remaining 37,550
|
|
472
|
-
Limit 50,000
|
|
473
|
-
|
|
474
|
-
Rate limit
|
|
475
|
-
Requests / minute 120
|
|
476
|
-
|
|
477
|
-
Billing period
|
|
478
|
-
2026-08-01 → 2026-09-01
|
|
464
|
+
npx netriskscan-cli upgrade
|
|
465
|
+
npx netriskscan-cli billing
|
|
479
466
|
```
|
|
480
467
|
|
|
481
|
-
|
|
482
|
-
|
|
468
|
+
`upgrade` opens the official plans page. `billing` opens the Developer Console for
|
|
469
|
+
subscriptions, invoices, and payment management. Sign in with the developer account
|
|
470
|
+
that owns the CLI key. After checkout, run `npx netriskscan-cli quota` with the same
|
|
471
|
+
key to read the effective plan and limits. Confirming payment from the CLI requires a
|
|
472
|
+
backend billing transaction API. CI, pipelines, and `--json` mode return a browser
|
|
473
|
+
action URL with a nonzero exit status.
|
|
483
474
|
|
|
484
475
|
## Batch processing
|
|
485
476
|
|
|
@@ -491,13 +482,9 @@ Use `netriskscan batch` as a batch IP lookup CLI or bulk IP reputation checker:
|
|
|
491
482
|
it at a file of one IP per line and get a risk result for every address, with
|
|
492
483
|
concurrency control and JSONL output for pipelines.
|
|
493
484
|
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
request draws on the [anonymous trial](#anonymous-trial), and the summary reports what the
|
|
498
|
-
server says is left. It never calls `/v1/ip-risk/batch` or
|
|
499
|
-
`/v1/ip-risk/query` - those endpoints are not open and currently return
|
|
500
|
-
`404 feature_not_available`.
|
|
485
|
+
The CLI sends one authenticated `GET /v1/ip-risk/{ip}` request per valid address
|
|
486
|
+
and retains input order. The separate server-side batch endpoint is documented in
|
|
487
|
+
the [Developer API reference](https://www.netriskscan.com/developer/docs).
|
|
501
488
|
|
|
502
489
|
Input is one IP per line; blank lines and lines starting with `#` are ignored:
|
|
503
490
|
|
|
@@ -526,36 +513,20 @@ Concurrency defaults to a conservative `5` and is capped at `20` regardless of w
|
|
|
526
513
|
pass - it is never unbounded. Make sure the concurrency you choose complies with the
|
|
527
514
|
limits shown in your NetRiskScan Developer Dashboard for your plan.
|
|
528
515
|
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
```text
|
|
534
|
-
4 succeeded, 0 failed
|
|
535
|
-
|
|
536
|
-
Anonymous trial
|
|
537
|
-
Available 19
|
|
538
|
-
Daily Limit 30
|
|
539
|
-
```
|
|
540
|
-
|
|
541
|
-
`Available` is the **lowest** `usage.remaining` seen in the batch, because concurrent
|
|
542
|
-
responses do not arrive in the order the server charged them. If any request came back
|
|
543
|
-
`anonymous_daily_limit_reached`, it reports `0`. The CLI never rejects an input file for
|
|
544
|
-
being longer than the daily allowance: it cannot know how much of today's allowance you
|
|
545
|
-
have already spent - only the server can. `--jsonl` output is unaffected; each line's
|
|
546
|
-
`result.usage` object already carries this, and no plain text is ever mixed into the
|
|
547
|
-
stream.
|
|
516
|
+
After a definitive credential or monthly quota refusal, the CLI stops starting
|
|
517
|
+
lookups. In-flight lookups can finish. Every IP retains its result row. Unstarted
|
|
518
|
+
lookups report `attempted: false` and can be selected for a later run.
|
|
548
519
|
|
|
549
520
|
### Options
|
|
550
521
|
|
|
551
|
-
| Option | Description
|
|
552
|
-
| ------------------- |
|
|
553
|
-
| `--api-key <key>` | API key for this run,
|
|
554
|
-
| `--base-url <url>` | Override the API base URL (advanced)
|
|
555
|
-
| `--concurrency <n>` | Concurrent requests (default `5`, max `20`)
|
|
556
|
-
| `--jsonl` | Newline-delimited JSON output (see [JSONL output](#jsonl-output))
|
|
557
|
-
| `--timeout <ms>` | Per-request timeout in milliseconds (default `10000`)
|
|
558
|
-
| `--max-retries <n>` | Max automatic retries per request for `429`/`503` (default `3`)
|
|
522
|
+
| Option | Description |
|
|
523
|
+
| ------------------- | ----------------------------------------------------------------------- |
|
|
524
|
+
| `--api-key <key>` | API key for this run, overrides the environment and OS credential store |
|
|
525
|
+
| `--base-url <url>` | Override the API base URL (advanced) |
|
|
526
|
+
| `--concurrency <n>` | Concurrent requests (default `5`, max `20`) |
|
|
527
|
+
| `--jsonl` | Newline-delimited JSON output (see [JSONL output](#jsonl-output)) |
|
|
528
|
+
| `--timeout <ms>` | Per-request timeout in milliseconds (default `10000`) |
|
|
529
|
+
| `--max-retries <n>` | Max automatic retries per request for `429`/`503` (default `3`) |
|
|
559
530
|
|
|
560
531
|
## JSON output
|
|
561
532
|
|
|
@@ -649,7 +620,7 @@ One JSON object per line, one line per input IP:
|
|
|
649
620
|
|
|
650
621
|
Designed for `netriskscan batch ips.txt --jsonl > results.jsonl` and downstream
|
|
651
622
|
line-oriented processing (`jq`, `grep`, log pipelines, etc.). A failed IP never causes
|
|
652
|
-
the
|
|
623
|
+
the output for the other IPs to be dropped. A command-level failure emits one line with an `error` object.
|
|
653
624
|
|
|
654
625
|
The envelope (`ip`, `ok`, `result` / `error`) belongs to the CLI; everything under
|
|
655
626
|
`result` is the API response verbatim, so `location`, `risk.reasons` and the Schema 1.6.0
|
|
@@ -659,6 +630,17 @@ domain, range or reason columns - so use `--jsonl` when you need the full record
|
|
|
659
630
|
|
|
660
631
|
## CI/CD
|
|
661
632
|
|
|
633
|
+
Configure `NETRISKSCAN_API_KEY` as a masked secret in your CI provider. For GitHub Actions:
|
|
634
|
+
|
|
635
|
+
```yaml
|
|
636
|
+
- run: npx --yes netriskscan-cli check 8.8.8.8 --json --fail-below 60
|
|
637
|
+
env:
|
|
638
|
+
NETRISKSCAN_API_KEY: ${{ secrets.NETRISKSCAN_API_KEY }}
|
|
639
|
+
```
|
|
640
|
+
|
|
641
|
+
JSON, JSONL, CI, and non-TTY invocations skip browser setup. A missing key fails
|
|
642
|
+
with exit code `3` and the machine-readable code `api_key_required`.
|
|
643
|
+
|
|
662
644
|
`--fail-below` and `--fail-on` turn `check` into an IP reputation CI check: use it
|
|
663
645
|
with policy flags as a build/deploy gate:
|
|
664
646
|
|
|
@@ -678,10 +660,10 @@ Rules:
|
|
|
678
660
|
|
|
679
661
|
## Environment variables
|
|
680
662
|
|
|
681
|
-
| Variable | Description
|
|
682
|
-
| ---------------------- |
|
|
683
|
-
| `NETRISKSCAN_API_KEY` |
|
|
684
|
-
| `NETRISKSCAN_BASE_URL` | Advanced:
|
|
663
|
+
| Variable | Description |
|
|
664
|
+
| ---------------------- | --------------------------------------------------------------------------------------------------------- |
|
|
665
|
+
| `NETRISKSCAN_API_KEY` | Developer API key from your secret manager. Takes precedence over the OS credential store. |
|
|
666
|
+
| `NETRISKSCAN_BASE_URL` | Advanced: set an alternate API base URL. Only explicitly supplied keys are used with alternate endpoints. |
|
|
685
667
|
|
|
686
668
|
## Exit codes
|
|
687
669
|
|
|
@@ -692,7 +674,7 @@ Rules:
|
|
|
692
674
|
| `2` | Invalid CLI argument |
|
|
693
675
|
| `3` | Authentication / authorization failure |
|
|
694
676
|
| `4` | API request failure |
|
|
695
|
-
| `5` | Rate limit
|
|
677
|
+
| `5` | Rate limit or monthly quota exceeded |
|
|
696
678
|
| `6` | CI policy failed (`--fail-below` / `--fail-on`) |
|
|
697
679
|
| `7` | Assessment unavailable (`--fail-below` used against a `null` index) |
|
|
698
680
|
|
|
@@ -700,81 +682,50 @@ These codes are stable and part of the CLI's public contract.
|
|
|
700
682
|
|
|
701
683
|
## API errors
|
|
702
684
|
|
|
703
|
-
|
|
685
|
+
With `--json` the CLI emits an error object on stdout:
|
|
704
686
|
|
|
705
687
|
```json
|
|
706
688
|
{
|
|
707
689
|
"error": {
|
|
708
690
|
"code": "quota_exceeded",
|
|
709
|
-
"message": "
|
|
710
|
-
"
|
|
691
|
+
"message": "API quota exceeded.",
|
|
692
|
+
"status": 429,
|
|
693
|
+
"requestId": "req_8f3ab21c9d",
|
|
694
|
+
"quota": { "used": 5000, "limit": 5000, "remaining": 0 },
|
|
695
|
+
"resetAt": "2027-01-01T00:00:00Z",
|
|
696
|
+
"upgradeUrl": "https://www.netriskscan.com/pricing.html"
|
|
711
697
|
}
|
|
712
698
|
}
|
|
713
699
|
```
|
|
714
700
|
|
|
715
|
-
The CLI prints this as:
|
|
716
|
-
|
|
717
|
-
```text
|
|
718
|
-
NetRiskScan API error
|
|
719
|
-
|
|
720
|
-
Code quota_exceeded
|
|
721
|
-
Status 429
|
|
722
|
-
Message Billing period quota exhausted.
|
|
723
|
-
Request ID req_8f3ab21c9d
|
|
724
|
-
```
|
|
725
|
-
|
|
726
701
|
Known error codes:
|
|
727
702
|
|
|
728
|
-
| HTTP status
|
|
729
|
-
|
|
|
730
|
-
| 400
|
|
731
|
-
| 400
|
|
732
|
-
| 400
|
|
733
|
-
| 401
|
|
734
|
-
| 403
|
|
735
|
-
| 403
|
|
736
|
-
| 404
|
|
737
|
-
| 404
|
|
738
|
-
| 429
|
|
739
|
-
| 429
|
|
740
|
-
|
|
|
741
|
-
|
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
otherwise. `anonymous_daily_limit_reached` is **never** retried, even though it is also a
|
|
746
|
-
`429`: the daily allowance cannot come back before the UTC reset, so retrying would only
|
|
747
|
-
repeat the same failure three more times. `400` / `401` / `403` / `404` are never retried
|
|
748
|
-
either.
|
|
749
|
-
|
|
750
|
-
Pass `--debug` to any command to include a stack trace on failure. Without it, errors
|
|
751
|
-
are shown as a clean summary - never a raw stack dump.
|
|
703
|
+
| HTTP status | `error.code` | Meaning |
|
|
704
|
+
| --------------------------------------------------------------------------- | ------------------------- | ----------------------------------------------------------------------------- |
|
|
705
|
+
| 400 | `invalid_ip` | The address is not a valid IPv4/IPv6 address |
|
|
706
|
+
| 400 | `invalid_request` | Unsupported query parameter, or request too large |
|
|
707
|
+
| 400 | `unsupported_parameter` | e.g. `forceRefresh` / `force_refresh` / `refresh` - not supported |
|
|
708
|
+
| 401 | `invalid_api_key` | Missing/malformed `Authorization` header, or key doesn't exist |
|
|
709
|
+
| 403 | `api_key_disabled` | Key revoked/expired, or account/plan unavailable |
|
|
710
|
+
| 403 | `scope_not_allowed` | Key lacks the scope required for this endpoint |
|
|
711
|
+
| 404 | `not_found` | Unknown path |
|
|
712
|
+
| 404 | `feature_not_available` | Endpoint is unavailable |
|
|
713
|
+
| 429 | `rate_limit_exceeded` | Per-minute request limit exceeded |
|
|
714
|
+
| 429 | `quota_exceeded` | Monthly quota exhausted |
|
|
715
|
+
| 503 | `temporarily_unavailable` | Transient rate-limit and service errors may be retried using `Retry-After` or |
|
|
716
|
+
| exponential backoff. Monthly exhaustion (`quota_exceeded` in OpenAPI, also |
|
|
717
|
+
| recognized as `monthly_quota_exceeded`) and authentication errors are never |
|
|
718
|
+
| retried. Use `error.code` to distinguish failures that share an exit code. |
|
|
719
|
+
| Pass `--debug` to `check` or `usage` for technical details in human output. |
|
|
752
720
|
|
|
753
721
|
## Rate limits & quota
|
|
754
722
|
|
|
755
|
-
|
|
756
|
-
through different channels. Do not read one as the other.
|
|
757
|
-
|
|
758
|
-
### Anonymous daily trial
|
|
759
|
-
|
|
760
|
-
Reported in the response body, on every request:
|
|
761
|
-
|
|
762
|
-
| Field | Meaning |
|
|
763
|
-
| ------------------ | ---------------------------------------------------------------- |
|
|
764
|
-
| `usage.mode` | `anonymous` when the request was served by the trial |
|
|
765
|
-
| `usage.remaining` | Requests still available today - authoritative, never recomputed |
|
|
766
|
-
| `usage.dailyLimit` | The trial's daily allowance |
|
|
767
|
-
| `usage.resetAt` | When the allowance resets (UTC day boundary) |
|
|
768
|
-
|
|
769
|
-
### API key quota
|
|
770
|
-
|
|
771
|
-
Every successful `/v1/*` response carries live rate limit and quota headers, so you
|
|
772
|
-
don't need a separate call to `/v1/usage` to know where you stand:
|
|
723
|
+
Authenticated IP lookups carry rate-limit and quota headers:
|
|
773
724
|
|
|
774
725
|
| Header | Meaning |
|
|
775
726
|
| ------------------------------------------------------------------- | --------------------------------------------------- |
|
|
776
727
|
| `X-RateLimit-Limit` / `X-RateLimit-Remaining` / `X-RateLimit-Reset` | Per-minute limit |
|
|
777
|
-
| `X-Quota-Limit` / `X-Quota-Used` / `X-Quota-Remaining` |
|
|
728
|
+
| `X-Quota-Limit` / `X-Quota-Used` / `X-Quota-Remaining` | Monthly quota |
|
|
778
729
|
| `X-Request-Id` | Request trace id (echoes yours, or a generated one) |
|
|
779
730
|
| `Retry-After` | Present on `429` responses |
|
|
780
731
|
|
|
@@ -795,25 +746,7 @@ Request ID req_xxxxxxxx
|
|
|
795
746
|
The package also exports `NetRiskScanClient` and its response and error types for direct
|
|
796
747
|
Node.js/TypeScript integration. The CLI and SDK use the same API client and response contract:
|
|
797
748
|
|
|
798
|
-
|
|
799
|
-
header and uses the anonymous trial:
|
|
800
|
-
|
|
801
|
-
```ts
|
|
802
|
-
import { NetRiskScanClient } from "netriskscan-cli";
|
|
803
|
-
|
|
804
|
-
const client = new NetRiskScanClient();
|
|
805
|
-
|
|
806
|
-
const { data } = await client.checkIp("1.1.1.1");
|
|
807
|
-
console.log(data.risk.index);
|
|
808
|
-
|
|
809
|
-
if (data.usage?.mode === "anonymous") {
|
|
810
|
-
console.log("available:", data.usage.remaining);
|
|
811
|
-
}
|
|
812
|
-
```
|
|
813
|
-
|
|
814
|
-
Pass `apiKey` to use Developer Account quota instead. `getUsage()` is account data and
|
|
815
|
-
always requires a key - without one it throws `NetRiskScanConfigError` before any request
|
|
816
|
-
is made:
|
|
749
|
+
Supply `apiKey` to use the Developer API and read the account's quota:
|
|
817
750
|
|
|
818
751
|
```ts
|
|
819
752
|
import { NetRiskScanClient, NetRiskScanApiError } from "netriskscan-cli";
|
|
@@ -879,7 +812,8 @@ See [examples/](examples/) for runnable scripts.
|
|
|
879
812
|
|
|
880
813
|
## Security
|
|
881
814
|
|
|
882
|
-
- The CLI
|
|
815
|
+
- The interactive CLI displays a newly saved key once after Google authorization.
|
|
816
|
+
Use `auth key` to view a saved key again. Error output and browser URLs omit the API key.
|
|
883
817
|
- There is no telemetry: **the CLI does not collect usage analytics or telemetry** of any
|
|
884
818
|
kind, in any version.
|
|
885
819
|
- If `--debug` needs to show an authorization value, it is redacted
|
|
@@ -901,20 +835,15 @@ This is a completely separate system from the netriskscan.com website's internal
|
|
|
901
835
|
`/api/public/*` endpoints - different auth, different response shapes, no compatibility
|
|
902
836
|
guarantees between the two. `netriskscan-cli` only ever calls `/v1/*`.
|
|
903
837
|
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
- `GET /v1/ip-risk/{ip}`
|
|
907
|
-
- anonymous access supported
|
|
908
|
-
- API key optional
|
|
909
|
-
- API key requests use account quota and require `ip-risk:read`
|
|
910
|
-
- `GET /v1/usage` - requires an API key with `usage:read`
|
|
838
|
+
Endpoints called by the CLI:
|
|
911
839
|
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
`
|
|
915
|
-
only available through the Developer Dashboard.
|
|
840
|
+
- `GET /v1/ip-risk/{ip}` with `ip-risk:read`
|
|
841
|
+
- `GET /v1/usage` with `usage:read`
|
|
842
|
+
- `POST /v1/cli/authorization` and its poll, exchange, and acknowledge endpoints for Google sign-in
|
|
916
843
|
|
|
917
|
-
|
|
844
|
+
The [OpenAPI contract](https://www.netriskscan.com/assets/paid-api-v1.yaml) also
|
|
845
|
+
documents the server-side batch endpoint. Key creation, rotation, and revocation
|
|
846
|
+
are available in the Developer Console.
|
|
918
847
|
|
|
919
848
|
See the official [Methodology](https://www.netriskscan.com/methodology.html) page for
|
|
920
849
|
how the NetRiskScan Index itself is computed (this project does not - and will not -
|
|
@@ -924,8 +853,7 @@ reimplement that logic client-side).
|
|
|
924
853
|
|
|
925
854
|
### How do I look up an IP address from the command line?
|
|
926
855
|
|
|
927
|
-
Run `netriskscan check <ip>`
|
|
928
|
-
trial. See [Quick start](#quick-start).
|
|
856
|
+
Run `npx netriskscan-cli check <ip>` with a Developer API key. See [Quick start](#quick-start).
|
|
929
857
|
|
|
930
858
|
### How do I check IP reputation from a terminal?
|
|
931
859
|
|
|
@@ -962,8 +890,8 @@ Yes - `netriskscan check <ip> --json` prints the raw API response, and
|
|
|
962
890
|
|
|
963
891
|
### Does NetRiskScan CLI work without an API key?
|
|
964
892
|
|
|
965
|
-
|
|
966
|
-
|
|
893
|
+
The CLI obtains a key through [interactive Google authorization](#getting-an-api-key).
|
|
894
|
+
For CI and machine output, set `NETRISKSCAN_API_KEY` before running the command.
|
|
967
895
|
|
|
968
896
|
## Official resources
|
|
969
897
|
|