Skip to content

Suggestions, probabilities and templates

phronesis suggest ranks several scripts per port instead of picking just one. Each candidate gets a sequence score and a probability conditional on the supplied list.

Usage

phronesis suggest --xml examples\demo-scan.xml --all-scripts --top-k 5
phronesis suggest --xml scan.xml --templates templates --format jsonl
phronesis suggest --xml scan.xml --personal-dir .\mes-scripts --top-k 8

Main options:

  • --max-candidates N: number of scripts scored per port, 24 by default.
  • --all-candidates: scores the whole filtered pool instead of capping it.
  • --top-k N: number of suggestions shown.
  • --min-prob P: hides suggestions below this threshold.
  • --stop-threshold P: decides STOP if its probability exceeds this threshold.
  • --all-scripts: adds the safe community scripts to the pool.
  • --allow-risky: allows the official intrusive, brute, dos, exploit, malware and fuzzer scripts.
  • --allow-external: allows scripts that contact a third-party service.
  • --templates DOSSIER: loads YAML templates.
  • --profile FICHIER: loads a profile of default values.
  • --explain: adds the reasons coming from templates. Without a template, nothing is added.

Being honest about probabilities

The model was distilled on rlvr-full2, which contains the benchmark's validation and test splits. The probabilities shown on these contexts are therefore in-sample and conditional on the candidate list. The shipped file carries calibration_scope: none; an in_sample scope only appears after a fit, and fresh_contexts requires the fresh set. Don't read them as a validated discovery frequency.

The softmax temperature is tuned with scripts/calibrate_probabilities.py, by minimizing NLL. Fitting doesn't turn the score into a validated probability, and a labeled fresh set, proven absent from data/distill.jsonl, is still required before writing calibrated: true.

The file nseft/calibration.json documents the chosen temperature, the scope and the limits. The shipped version has not been fitted: temperature is 1.0, calibration_scope is none and calibrated is false. The best NLL on the validation split is around 3.0, but no fit is published until the fresh set has been measured.

Personal scripts are scored zero-shot. Their score reflects how plausible the id and description are, not a validated probability.

Templates

A template is a YAML or JSON file, with no code. It matches the Nmap state and adjusts the candidates:

schema: 1
id: http-any-port
when:
  service: [http, https, domain]
  product: ["*nginx*", "*apache*", "*httpd*"]
apply:
  scripts: ["http-*", "ssl-*"]
  add: ["http-title"]
  exclude: ["http-brute", "*-dos"]
  logit_boost: 0.7
  stop: false
  • when: AND conditions; lists are ORs; globs are case-insensitive.
  • scripts: existing candidate scripts to boost.
  • add: adds a script from the catalog, only if the security filters allow it.
  • exclude: removes candidates; wins over boosts.
  • logit_boost: additive adjustment in logit space.
  • stop: forces STOP for matching ports.

Bundled examples: templates/http-any-port.yaml, templates/wordpress.yaml.

Profiles

A YAML or JSON profile sets the defaults for a session, with no code:

phronesis suggest --xml scan.xml --profile templates/example-profile.yaml

It can set templates, the pool, top_k, max_candidates, min_prob, stop_threshold, the format, paths and the device. Options passed explicitly on the command line win. Relative paths start from the profile's folder. A profile larger than 64 KiB or with an unknown key is rejected.

Personal scripts

phronesis index --personal .\mes-scripts --output .\mes-scripts\catalog.jsonl
phronesis suggest --xml scan.xml --personal-dir .\mes-scripts

A personal script is included automatically if it is documented, classified as safe and placed in a dedicated folder. Scripts with no description or no categories stay explicit. When an id duplicates an official one, the official script wins by default; --personal-overrides reverses the priority.

Updating the database

phronesis update-db --check
phronesis update-db --dry-run --source-dir D:\nse-scripts
phronesis update-db --registry nseft-sources.json --source nmap-official --dry-run
phronesis update-db --registry nseft-sources.json --source nmap-official-tarball --online
phronesis update-db --rollback

update-db builds a staging library, checks hashes and the catalog, backs up the old library, then replaces it. It touches neither the model, nor the templates, nor personal scripts. No script is executed during the update. The registry pins archive SHA-256 values and only accesses the network with --online. Unlicensed sources are included with a warning; --strict-license blocks them. See NSE library.

Limits

  • A probability depends on the supplied list; adding a candidate changes the values.
  • The score is a sum of log-probabilities, with no length normalization: a long id may be slightly penalized.
  • On CPU, the model runs in float32. Scoring takes a median of 1.7 to 2.6 s per port on the test split, with 3 to 5 candidates, prompt included, and about 6.8 s with 14 candidates. The cost grows with the number of candidates and the prompt length.
  • A port with more than 14 candidates or more than 1,572 prompt tokens falls outside the training range. suggest flags it with a warning and with "in_training_range": false in JSONL. Outside the training data, on the check set, strict top-1 drops to 13.7 %.
  • Templates can't bypass the security filters.
  • update-db checks integrity by hash and commit, not the authenticity of a compromised source.