Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 3 additions & 12 deletions compliance-monitor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,23 +183,14 @@ The final field is the desired state; the other fields are used to determine the
(within one report, version and check uniquely determine a result; the scope is given here as well
in case reports at some point contain multiple scopes).

### GET /status/{subject}
### GET /status

Returns the current status of the subject. Use the `Accept` header to select desired content type:

- `text/html` (default): a snippet of HTML suitable for the end user;
- `image/png`: a PNG image of a badge;
- `application/json`: a short summary in JSON format.
Returns the current status of all subjects in JSON format.

Query parameters:

- `subject` (optional): restrict subject
- `scopeuuid` (optional): restrict scope
- `version` (optional): restrict version
- `privileged_view` (optional `0` or `1`, default `0`): request privileged view (see below)

If the privileged view is requested, then this request needs to be authenticated (via basic auth),
either for the same subject or for some account with role `read_any`. This view will immediately
show any non-pass result, whereas otherwise, such a result needs to be verified manually.

### GET /metrics/{subject}

Expand Down
7 changes: 2 additions & 5 deletions compliance-monitor/monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -548,18 +548,15 @@ def convert_result_rows_to_dict2(
@app.get("/status")
async def get_status(
request: Request,
account: Annotated[Optional[tuple[str, str]], Depends(auth)],
conn: Annotated[connection, Depends(get_conn)],
subject: str = None, scopeuuid: str = None, version: str = None,
subject: str = None, scopeuuid: str = None,
):
check_role(account, subject, ROLES['read_any'])
# note: text/html will be the default, but let's start with json to get the logic right
accept = request.headers['accept']
if 'application/json' not in accept and '*/*' not in accept:
# see https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/406
raise HTTPException(status_code=406, detail="client needs to accept application/json")
with conn.cursor() as cur:
rows2 = db_get_relevant_results2(cur, subject, scopeuuid, version, approved_only=False)
rows2 = db_get_relevant_results2(cur, subject, scopeuuid, approved_only=False)
return convert_result_rows_to_dict2(rows2, get_scopes(), include_report=True)


Expand Down
Loading