Restrict profiles per session: read-only, interactive-only and deny-list permissions

Ouverte
#558 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

Personne n'a encore pris cette issue.

Évaluation

Difficulté
5/5
Temps estimé
Plus d'une semaine
Accessibilité débutants
35/100
Type d'issue
Fonctionnalité
Clarté
Plutôt claire
Activité
Active
Stack technique
go
Domaine
authorization, cli

Piste de recherche

The issue points to docs/auth.md and describes changes to core auth resolution and verb dispatch, but does not name source files or tests. Start by reading docs/auth.md and tracing how the active profile and canonical command are resolved before request construction. Done means the policy rules are enforced with a distinct non-zero refusal code and the error identifies the profile, command, rule, and policy path; the open questions need decisions first.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

enhancement

Problem

Any process that can run harness can use every profile and run every command, including deletes. For production-like profiles, and for AI-agent or autonomous use, there is no way to say "this profile is read-only" or "this profile must not run unattended".

Proposed

A cooperative guardrail, not a security boundary: the CLI reads a policy file and refuses commands the active profile doesn't allow. It does not try to stop a process that is working around it (env var mode, direct API calls, other profiles).

Policy file

A TOML file next to the profile files (path TBD, e.g. ~/.harness/permissions.toml), edited by hand. [all] applies to every profile; a [<profile>] section adds to it.

[all]
deny_commands = ["delete project"]

[harness0]
read_only = true
interactive = true

[default]
deny_commands = ["delete repository"]
  • Per-profile options, each independent (a profile is not in a "mode"); a command runs only if every option and the deny list allow it:

    • read_only: only read verbs (list, get) run. execute is blocked unless listed in allow_commands (for read-type executes such as hql:run).
    • interactive: refuses when stdin or stdout is not a terminal, so scripts, CI and agents can't use the profile.
  • deny_commands: commands not allowed under the profile, matched against the canonical verb noun[:variant]. An entry is one of:

    • a literal command: delete repository
    • a wildcard with *: delete *
    • a regular expression wrapped in slashes: /^(delete|update) (repository|branch)$/
  • Deny lists from [all] and the profile section add up; a profile section can't remove an [all] entry.

  • Session profile is chosen the usual way (export HARNESS_PROFILE=<name>); see docs/auth.md.

Enforcement

One check before the request is built, after noun aliases are resolved (repositories -> repository), so spec-driven commands and custom handlers are covered. A refusal exits with a distinct non-zero code.

Error message

One message for every reader (human, script or agent): which profile, which command, which rule blocked it, and where the policy file is. Example:

blocked: 'delete repository' is not allowed by profile 'harness0' (read_only) - see <policy file path>

Open questions

  • Regex syntax (Go RE2), anchoring (whole command vs substring), and the /.../ delimiter for telling a regex from a literal.
  • Policy file name and location, and Windows path if supported.
  • Exact exit code.
  • allowed_profiles (refuse --profile other than the pinned one) as a follow-up.
  • Whether interactive should treat pipeline mode (docs/auth.md) as non-interactive and refuse.
  • Core change (auth resolution and verb dispatch); land before any module work.

Related: #157.

Langage dominant
Go
Étoiles
29
Forks
24
Merge moyen
1 j 9 h
PR mergées (30 j)
111

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de harness/cli

Toutes les issues de harness/cli

Issues similaires

Plus d'issues Go

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.