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
9 changes: 9 additions & 0 deletions design-system/components/alerts.css
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,12 @@
border-color: #f0b3af;
color: var(--color-error);
}

/* "Nothing here yet" / "nothing matches" message at the top of a page or
list (the empty_state() macro in the dashboard's _macros.html). */
.empty-state {
margin-top: var(--space-6);
}
.empty-state__action {
margin: var(--space-3) 0 0;
}
9 changes: 9 additions & 0 deletions src/secfoo/web/static/design-system/components/alerts.css
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,12 @@
border-color: #f0b3af;
color: var(--color-error);
}

/* "Nothing here yet" / "nothing matches" message at the top of a page or
list (the empty_state() macro in the dashboard's _macros.html). */
.empty-state {
margin-top: var(--space-6);
}
.empty-state__action {
margin: var(--space-3) 0 0;
}
15 changes: 15 additions & 0 deletions src/secfoo/web/templates/_macros.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,18 @@
<span class="badge {{ a.responsible_ai_status | responsible_ai_status_badge }}">{{ a.responsible_ai_status }}</span>
{%- else %}<span class="ds-caption">&mdash;</span>{% endif -%}
{% endmacro %}

{#- Shared "nothing here yet" box: says what's missing and how to start.
Use for a page or list that has no data at all (not for "your filters
matched nothing" -- that should offer to clear the filters instead). -#}
{% macro empty_state(title, action_href=None, action_label=None) %}
<div class="alert alert--info empty-state" role="status">
<div>
<div class="alert__title">{{ title }}</div>
<div>{{ caller() }}</div>
{%- if action_href %}
<p class="empty-state__action"><a class="btn btn--primary btn--sm" href="{{ action_href }}">{{ action_label }}</a></p>
{%- endif %}
</div>
</div>
{% endmacro %}
10 changes: 9 additions & 1 deletion src/secfoo/web/templates/activities/detail.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
{% extends "base.html" %}
{% from "_macros.html" import findings_badges %}
{% from "_macros.html" import findings_badges, empty_state %}
{% set verdict_projects = projects | selectattr("design_verdict") | list %}
{% block title %}{{ skill.nav_label }} — secfoo{% endblock %}
{% block content %}
<span class="ds-overline">Activity</span>
<h1>{{ skill.name }}</h1>
<p class="ds-body" style="color:var(--color-text-muted);max-width:44rem">{{ skill.description }}</p>

{% if run_count == 0 %}
{% call empty_state("No " ~ skill.name ~ " runs yet", "/assessments", "Go to assessments") %}
The figures below fill in after the first run. Start one from an
assessment's <strong>Run Assessment</strong> page, or run
<code>secfoo run --skill {{ skill.id }}</code>.
{% endcall %}
{% endif %}

{% if dash %}
{% include "activities/architecture_dashboard.html" %}
{% endif %}
Expand Down
9 changes: 7 additions & 2 deletions src/secfoo/web/templates/assessments/list.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% extends "base.html" %}
{% from "_macros.html" import findings_badges, responsible_ai_badges %}
{% from "_macros.html" import findings_badges, responsible_ai_badges, empty_state %}
{% block title %}secfoo — Assessments{% endblock %}
{% block content %}
<div style="display:flex;justify-content:space-between;align-items:flex-start;gap:var(--space-6);flex-wrap:wrap">
Expand Down Expand Up @@ -62,7 +62,12 @@ <h1>Assessment register</h1>
</tbody>
</table>
</div>
{% elif counts.all == 0 %}
{% call empty_state("No assessments yet", "/assessments/new", "New Assessment") %}
An assessment groups the security checks for one application. Create one,
then choose which checks to run on it.
{% endcall %}
{% else %}
<div class="alert alert--info" style="margin-top:var(--space-6)"><div>No assessments match these filters.</div></div>
<div class="alert alert--info empty-state" role="status"><div>No assessments match these filters. <a href="/assessments">Clear filters</a></div></div>
{% endif %}
{% endblock %}
9 changes: 8 additions & 1 deletion src/secfoo/web/templates/third_party.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% extends "base.html" %}
{% from "_macros.html" import findings_badges %}
{% from "_macros.html" import findings_badges, empty_state %}
{% block title %}secfoo — Third-Party{% endblock %}
{% block content %}
<span class="ds-overline">Third-Party</span>
Expand All @@ -8,6 +8,13 @@ <h1>Third-party assessments</h1>
{{ counts.total }} third-party assessment(s) &middot; AI-BOM: {{ models_count }} model(s), {{ tools_count }} tool(s) tracked.
</p>

{% if counts.total == 0 %}
{% call empty_state("No third-party assessments yet", "/assessments/new", "New Assessment") %}
Create an assessment with type <strong>Third-Party</strong> and upload the
vendor's documents (SOC 2 report, ISO certificate, pen test report or
questionnaire). The conformance view below fills in from that evidence.
{% endcall %}
{% endif %}
<div class="card" style="margin-top:var(--space-6)">
<h4 class="card__title">Vendor CCM v4 conformance</h4>
<p class="card__body" style="margin-bottom:var(--space-4)">
Expand Down
17 changes: 17 additions & 0 deletions tests/test_web/test_activity_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,23 @@ def test_activity_page_empty_state(client):
assert "No project has been scanned with this activity yet" in resp.text


@pytest.mark.parametrize("skill_id", ["sast", "security-architecture-review", "threat-modeling", "prompt-review"])
def test_activity_page_explains_why_it_is_empty_before_the_first_run(client, skill_id):
# The dashboards render all-zero charts with no data, so the top of the
# page has to say nothing has run yet, and how to start.
resp = client.get(f"/activities/{skill_id}")
assert resp.status_code == 200
assert "runs yet" in resp.text
assert f"secfoo run --skill {skill_id}" in resp.text


def test_activity_page_hides_the_no_runs_message_once_it_has_run(client):
_seed_run(skill_id="sast", high=1)
resp = client.get("/activities/sast")
assert resp.status_code == 200
assert "runs yet" not in resp.text


def test_activity_page_shows_per_project_rollup(client):
_seed_run(skill_id="sast", project_name="acme/app", high=2, medium=1)
_seed_run(skill_id="sast", project_name="acme/other", high=1)
Expand Down
15 changes: 14 additions & 1 deletion tests/test_web/test_assessment_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,22 @@ def _create_assessment(*, assessment_type: str = "internal", status: str = "read


def test_assessments_list_empty_state(client):
# No assessments at all: say so and offer to create one -- not
# "no assessments match these filters", which reads as a filter problem.
resp = client.get("/assessments")
assert resp.status_code == 200
assert "No assessments match" in resp.text
assert "No assessments yet" in resp.text
assert "No assessments match" not in resp.text
assert 'href="/assessments/new"' in resp.text


def test_assessments_list_filters_matching_nothing_offers_to_clear_them(client):
_create_assessment(status="ready")
resp = client.get("/assessments?status=completed")
assert resp.status_code == 200
assert "No assessments match these filters" in resp.text
assert "Clear filters" in resp.text
assert "No assessments yet" not in resp.text


def test_assessments_list_shows_created_assessment(client):
Expand Down
16 changes: 16 additions & 0 deletions tests/test_web/test_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,3 +145,19 @@ def test_mermaid_init_js_sanitizes_agent_generated_content():

content = (STATIC_DIR / "js" / "mermaid-init.js").read_text()
assert 'securityLevel: "strict"' in content


def test_third_party_page_explains_it_is_empty(client):
resp = client.get("/third-party")
assert resp.status_code == 200
assert "No third-party assessments yet" in resp.text


def test_third_party_page_hides_the_empty_message_once_one_exists(client, tmp_path):
project_id, _run_uuid = _seed_run(tmp_path)
repo = RunRepository()
repo.create_assessment(project_id=project_id, assessment_type="third_party", status="ready")
repo.close()
resp = client.get("/third-party")
assert resp.status_code == 200
assert "No third-party assessments yet" not in resp.text
Loading