Skip to content

fix/update api - #2

Merged
derevnjuk merged 5 commits into
masterfrom
fix/update_api
Jul 26, 2019
Merged

derevnjuk merged 5 commits into
masterfrom
fix/update_api

Conversation

@derevnjuk

Copy link
Copy Markdown
Member

No description provided.

@derevnjuk
derevnjuk merged commit 9a4aabb into master Jul 26, 2019
derevnjuk added a commit that referenced this pull request Jul 26, 2019
…g api changes (#2)

* audit and fix vulnerabilities
* fix config loading
* Commands: improve logs
* bump version
* other minor changes and improvements
@Sija
Sija deleted the fix/update_api branch October 24, 2019 18:36
aborovsky added a commit that referenced this pull request Nov 9, 2026
…rovider options (#816)

## What

Configuration for PKCS#11 (smart card / token) client certificates on
`bright-cli repeater`, for HTTPS targets. This PR only parses, validates
and registers the options; the TLS integration comes in a follow-up PR.

**`--pkcs11-cert <json>`** (repeatable). Also accepted:
- `REPEATER_PKCS11_CERT`: one JSON object, or a JSON array of them;
- `pkcs11Cert` in `.brightrc*`: an object, or an array of objects.

| Field | Required | Default |
|---|---|---|
| `hostname` | yes | – |
| `module` | yes, unless `--pkcs11-module` is set | `--pkcs11-module` |
| `pinFile` or `pinEnv` | exactly one | – |
| `port`, `token`, `object`, `id` (hex `CKA_ID`) | no | – |
| `cert` | no | `"token"` (or a PEM file path) |
| `maxConcurrency` | no | `1` |

**`--pkcs11-module <path>`** is the default vendor library for entries
without `module`. **`--pkcs11-provider <path>`** overrides the OpenSSL
provider plugin location.

## Validation

All of it runs before the repeater starts, and each error names the
entry, e.g. `Option --pkcs11-cert #2 (hostname "b.example.com"): specify
"module" …`.
- Missing hostname, module or PIN source, or two PIN sources.
- A literal `pin`, which would land in argv, `ps` and the daemon service
definition.
- Unknown or misspelled fields.
- `pinEnv`:
- must be a variable name; the value is never echoed, in case someone
types the PIN there;
- must not start with `REPEATER_`, because yargs reads those names as
options;
  - must be set.
- `module`, `pinFile`, `cert`, `--pkcs11-module` and `--pkcs11-provider`
must be existing files. `pinFile` must also be readable. All paths are
resolved to absolute ones.
- An invalid `port`, `id` or `maxConcurrency`.
- `--daemon` rejects `pinEnv`, because the service doesn't inherit the
shell environment. `--remove-daemon` skips the checks.

## Also fixed

`--cert` entries from the config file arrive as objects, or as a single
object, and used to crash in `JSON.parse`. Both options now accept
strings, objects and arrays.

## Checks

- `lint`, `format`, `build` and `test:unit` (29 suites, 402 tests) pass.
`tsc` reports no new errors.
- New specs:
  - `Pkcs11CertParser.spec.ts`: `parse` and `resolveFile`;
- `RunRepeater.spec.ts`: registration, defaults, provider, the real
`pinEnv`, `REPEATER_PKCS11_CERT` arrays, config-file objects and arrays,
`--cert` on the command line, daemon install and remove, and rejection.
- Manual: `repeater --help` lists the options, and an invalid entry
exits with code 1 and the entry-specific message, the same way the
existing `--id` validation fails.
- An automated review (`semantic_reviewer`) of the first revision found
12 issues; all are addressed in the second commit.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant