Usage¶
shaar [--version] COMMAND [options]
Command |
What it does |
|---|---|
|
Read access exports, assign a reviewer to every entry, and write the campaign and one packet per reviewer. |
|
Read the returned packets, check each against the campaign, and write the decision record. |
|
Check a later export: were the accepted removals made? |
|
Write the PowerShell exporter, to run on a domain-joined computer yourself. |
|
Run the exporter on a domain controller over WinRM. Needs the |
|
Read Entra ID through Microsoft Graph. Needs the |
|
Print a JSON Schema. |
|
Write synthetic exports, returned packets, and a later export. |
Run shaar COMMAND --help for the options of any command. Running shaar with no command prints the help and exits with code 2.
campaign¶
shaar campaign INPUT... -o DIR --name NAME --reviewers {manager,owner,map} [options]
Option |
Meaning |
|---|---|
|
One or more access inputs: shaar exports or CSV files. shaar detects the kind of each from its content. Inputs from different systems can be mixed. |
|
Folder for the campaign. Required. Created if needed. |
|
The campaign’s name. It appears in every packet and report. Required. |
|
Who reviews each entry: |
|
A CSV that names reviewers. Required with |
|
The date decisions and removals are due, as |
|
A TOML column map for CSV inputs. See CSV column maps. |
|
A built-in column map: |
|
The one resource a members-only CSV lists, such as the group an Entra portal download came from. |
|
Replace this command’s own files that already exist. See what |
--map, --preset, and --resource apply to every CSV input of the command. Run a different command, or write one map that fits all the CSV files, when your CSV files differ.
The command writes campaign.json, one packet for each reviewer, the campaign report in JSON, Markdown, and HTML, rows.csv, unassigned.csv when any entry has no reviewer, and manifest.json. See Reports and output.
Keep the campaign folder. shaar decisions and shaar verify need campaign.json, and a second campaign run makes a new campaign with a new id, so its packets do not match the first.
A reviewer who has an email address gets one packet, even when that person appears in several systems. See Campaigns.
decisions¶
shaar decisions CAMPAIGN PACKET... -o DIR [--require-comment DECISION] [--force]
Option |
Meaning |
|---|---|
|
The campaign folder, or its |
|
One or more returned workbooks. Give every file you received. |
|
Folder for the decision record. Required. |
|
A decision that must have a comment: |
|
Replace files that already exist. |
Two packets must not share a file name, because every decision cites its packet by name. shaar refuses the run with exit code 2 and names the file.
The command writes decisions.json, removals.csv, attention.csv, decisions.csv, the decisions report in JSON, Markdown, and HTML, and manifest.json. See Reports and output.
verify¶
shaar verify CAMPAIGN DECISIONS LATER... -o DIR [options]
Option |
Meaning |
|---|---|
|
The campaign folder, or its |
|
The decisions folder, or its |
|
One or more exports or CSV files read after the removals were due. |
|
Folder for the verification report. Required. |
|
When the later access was read, as an ISO 8601 time such as |
|
As for |
|
Replace files that already exist. |
shaar refuses a decision record that does not belong to the campaign as written, with exit code 3. The command writes removals.csv, kept_but_gone.csv, new_since_review.csv, the verification report in JSON, Markdown, and HTML, and manifest.json. See Verification.
exporter¶
shaar exporter DIR [--force]
Writes Export-ShaarAccess.ps1 into DIR, creating the folder if needed, and prints the command that runs it. It replaces an existing script only with --force. See Collecting.
collect ad¶
shaar collect ad --host HOST (--group GROUP... | --search-base DN | --privileged) -o FILE [options]
Runs the exporter on a domain controller over PowerShell remoting and writes its export. Needs the ad extra. Collecting explains the requirements and the security rules.
Option |
Meaning |
|---|---|
|
The controller’s fully qualified DNS name, such as |
|
Groups to export, each a name, a distinguished name, or a SID. Give one or more. |
|
A distinguished name. Every group below it is exported. |
|
Export the well-known privileged groups. |
|
|
|
|
|
A secret reference for the password. Never the password itself. |
|
|
|
From 1 to 65535. Default: 5986 for |
|
A PEM file of certificate authorities for HTTPS. Refused with |
|
Stop when the exporter sends nothing for this many seconds, from 1 to 86400. Default: 600. |
|
The export file to write. Required. |
|
Replace an existing file. |
Give at least one of --group, --search-base, and --privileged. --username and --secret go together: give both, or leave both out to use the current Kerberos ticket. --auth ntlm always needs both. These pairings exit with code 2. A bad --host or --username, and --ca-file with --transport http, exit with code 3.
collect entra¶
shaar collect entra --tenant TENANT --client-id ID \
(--certificate PATH | --client-secret REF | --device-code) \
(--group ID|NAME... | --all-security-groups | --roles | --pim) -o FILE [options]
Reads Entra ID through Microsoft Graph with GET requests only and writes a shaar export. Needs the entra extra. See Collecting.
Option |
Meaning |
|---|---|
|
The tenant id (a GUID) or a verified domain name. Required. |
|
The application (client) id, a GUID. Required. |
|
A PEM or PFX file for certificate sign-in. |
|
A secret reference for the certificate’s password. Needs |
|
A secret reference for the application’s client secret. |
|
Sign in as yourself with a device code. |
|
|
|
Groups to read, each an object id or a display name that matches exactly one group. Give one or more. |
|
Read every security-enabled group. |
|
Read active directory role assignments. |
|
Read eligible (Privileged Identity Management) role assignments. |
|
The export file to write. Required. |
|
Replace an existing file. |
Give exactly one of --certificate, --client-secret, and --device-code, and at least one of --group, --all-security-groups, --roles, and --pim. Missing choices exit with code 2. A missing extra, a refused sign-in, an unreadable certificate or secret, or an existing output file exits with code 3. A part Graph would not return does not stop the run: it is printed as a not read: line and recorded in the file.
schema¶
shaar schema {campaign-report-v1|decisions-report-v1|verify-report-v1|manifest-v1}
Prints a JSON Schema for the installed version, with no network access. See Reports and output.
example¶
shaar example DIR [--force]
Writes a synthetic review into DIR: exports for a made-up domain, corp.example, an Entra export, a CSV from a made-up finance application with its column map, returned packets, and a later export. It then prints three commands to run in order: the first makes the campaign (it sets SOURCE_DATE_EPOCH to the time the returned packets were prepared for, because a campaign made at another time has another id and refuses them), the second reads the returned packets, and the third verifies. All three exit with code 1 on purpose; the quickstart shows each result. Without --force, shaar refuses to replace existing files.
Replacing existing files¶
Without --force, shaar never replaces a file. With it, shaar replaces the files the command writes and takes away files an earlier run of the same command wrote there that this run does not (a packet for a reviewer who no longer has entries, for example). It never takes away campaign.json, decisions.json, or a packet when another command is writing, and it refuses an output folder that is, or contains, the folder of the campaign or decision record the command was given, or that already holds a record the command does not write. It also never replaces or takes away a file the command read: an access export, a column map, a reviewer map, a returned packet, or a later export. If an input is, or is linked to (a symbolic link either way, or a hard link), a file the run would write or take away, the run stops with exit code 3 before anything is written, with or without --force. shaar collect does the same for its CA file, certificate and file: secrets, before it reads a secret or connects. Use a new folder for each run.
Exit codes¶
Code |
Meaning |
|---|---|
|
Success, and nothing needs attention. Also |
|
|
|
The command was used incorrectly: an unknown or missing option, a bad value, options that do not go together, two packets with one file name, or |
|
An input, output, or collection problem: an unreadable or oversized input, a CSV with no column map, a bad map, a campaign or decision record that fails its digest, an output file that exists without |
|
An internal error in shaar. This is a bug. Please report it. |
Exit code 1 never means the tool failed. It means read the report.
When each command returns 1¶
Command |
Exit code |
|---|---|
|
At least one entry has no reviewer, any input could not be read in full (a problem is recorded), or the inputs hold no access entries at all. The files are written either way. |
|
The record is not complete: any entry lacks an accepted decision (undecided, invalid, altered, conflict, or unassigned), any accepted decision is Unsure, any row did not belong to its packet, any returned file was rejected or unreadable, or the campaign itself recorded problems reading its inputs or had a resource it did not read in full (entries may be missing from the review). |
|
Any accepted Remove is not verified as removed (pending, failed, or unknown), or the decision record is not complete for any of the reasons in the |
A verify run exits with 0 only when the decision record is complete and every accepted removal is verified. With a complete record and no accepted removals it exits with 0. With an incomplete record it exits with 1 even if no removal was decided, and says so in its headline and in the report.
Size limits¶
Every file shaar reads has a size limit, so that a damaged or hostile file cannot use all of a machine’s memory. A limit is never silent. When an input is over a limit, the command stops, names the limit and how to raise it, and exits with code 3; nothing is written. When a returned packet is over a limit, shaar decisions records the packet as unreadable with that reason, so the decision record is incomplete and the command exits with code 1.
The defaults are well above the size of any realistic enterprise review. To read something larger, raise the limit for that run with --limit NAME=VALUE, which campaign, decisions and verify accept and which can be repeated. A value is a whole number from 1 to 1,099,511,627,776 (_ may separate digits). Anything else is a usage error (exit code 2), and so is an unknown name.
shaar campaign export.csv --map map.toml --limit csv-rows=5000000 --limit csv-bytes=2147483648 ...
Name |
What it limits |
Default |
|---|---|---|
|
The size of one CSV input, in bytes. |
268,435,456 |
|
The data rows in one CSV input. |
2,000,000 |
|
The size of one shaar export (JSON Lines), in bytes. |
536,870,912 |
|
The length of one line of a shaar export. A longer line is skipped and recorded as a problem, so the run cannot be clean. |
1,048,576 |
|
The size of a reviewer map. |
16,777,216 |
|
The size of a column map. |
1,048,576 |
|
The size of |
268,435,456 |
|
The size of |
268,435,456 |
|
The size of one returned packet file. |
67,108,864 |
|
The rows on a packet’s sheet. Packets are written with 10 percent fewer, so every packet can be read when it comes back. |
100,000 |
|
The cells with content in a packet. Follows |
1,600,000 |
|
The size of a packet once unzipped. Packets are written 25 percent smaller. |
67,108,864 |
|
The XML elements in one part of a packet. Follows |
6,400,000 |
Every run records the limits it used in limits in its manifest.json, whether or not it raised any, so a reader of the output can see what the run would have refused. The fixed safety limits that no realistic file reaches (zip entries, the 200 to 1 expansion ratio, nesting depth, cell text length) have no option.
Repeatable output¶
Every report records the time it was written. Set SOURCE_DATE_EPOCH to a whole number of seconds since 1970-01-01 UTC, and shaar uses that time instead of the clock. The campaign’s created_at, its id, the row identifiers, the packet workbooks (their zip dates and document properties), the reports, and the manifests are then byte-for-byte the same for the same inputs. shaar collect entra also takes its collected_at from it.
SOURCE_DATE_EPOCH=1793000000 shaar campaign ad.jsonl -o campaign --name Q4 --reviewers manager
A value that is not a whole number of seconds, or is out of range, is ignored and shaar uses the clock. It does not warn.
Output folders and files¶
A new output folder is readable only by your user account on Linux and macOS, and so is every file in it.
Without
--force, shaar never replaces an existing file, even one that appears while it runs. It stops with exit code3and names the files.With
--force, shaar moves the old files aside and puts them back if any step fails, so the folder holds either the old set or the new set. Files the earlier run’smanifest.jsonlists that the new run does not write, such as a packet for a reviewer who is no longer in the campaign, are taken away too. Other files in the folder are left alone.A symbolic link at a target name is replaced, never followed.
The manifest is written last. A manifest means every other file is in place.
Run one shaar at a time per output folder. A crash or power loss while writing can leave a partial file or
.shaar-old-*backups. The manifest lists the size and SHA-256 of every file from its run, so that is detectable.
shaar sets no access rules on Windows. Check the folder’s permissions there.
Use in a pipeline¶
shaar campaign, decisions, and verify need no network and no secrets, so they run anywhere Python does.
shaar verify campaign decisions after/ad.jsonl -o verification || test $? -eq 1
Treat exit code 1 as read the report, and codes 2, 3, and 4 as failures. Collect on a schedule by giving shaar collect a secret reference that your scheduler fills in, for example --secret env:SHAAR_PASSWORD. Never put a password on the command line.