Skip to content

ServerKit is a lightweight, modern server control panel for managing web applications, databases, and services on your VPS or dedicated server. Built with Python/Flask backend and React frontend.

25.5 KB
Raw Blame
// ============================================
// SECURITY PAGE (redesign — infra console look)
// ============================================
// Page shell + all 13 tabs. Consumes the sk- design-system primitives
// (Pill, MetricCard, SegControl, ScoreGauge, Feed, .sk-dtable, .sk-info-row);
// page-specific atoms are prefixed `sec-`. Per-tab blocks stay scoped under
// their tab-root class so nothing leaks to other pages.

.security-page {
    // ── card chrome (all tabs) ──────────────────────────────
    .tab-content {
        .card {
            background: var(--surface);
            border: 1px solid var(--border-soft);
        }

        .card-header {
            margin-bottom: $space-4;

            // Mono-uppercase eyebrow section headers
            h3 {
                margin: 0;
                display: flex;
                align-items: center;
                gap: $space-tight;
                font-size: $text-xs;
                font-weight: $font-weight-semibold;
                color: var(--text-faint);

                &.sec-listtitle--green { color: var(--green); }
                &.sec-listtitle--red { color: var(--red); }
            }
        }

        // Flush variant: the card drops its padding so the table bleeds to
        // its edges; .sk-dtable-wrap already renders frameless inside .card.
        .card.sec-flush {
            padding: 0;

            .card-header { padding: $space-4 $space-4 0; }
            > .card-body { padding: 0 $space-4 $space-4; }
        }

        // Stateful card borders
        .card.scan-progress { border-color: var(--accent-dim); }
        .card.card-warning { border-color: rgba(245, 185, 69, 0.35); }
    }

    .card-actions {
        display: flex;
        gap: $space-2;
    }

    // Right-end cluster in a table card header (sort/columns menus + actions).
    // Same layout as .card-actions but outside the legacy `card*` namespace the
    // ESLint no-restricted-syntax rule flags on new markup.
    .sec-tableactions {
        display: flex;
        align-items: center;
        gap: $space-2;
    }

    // ── shared page atoms ───────────────────────────────────
    // Count suffix inside an eyebrow heading ("Banned IPs · 4")
    .sec-count {
        font-weight: $font-weight-medium;
        color: var(--text-faint);
        letter-spacing: 0;
    }

    // Severity / state chip (mono uppercase on a semantic wash) —
    // shape from the shared %sk-state primitive (_design-system.scss)
    .sec-state {
        @extend %sk-state;

        &--red    { color: var(--red);    background: var(--red-bg); }
        &--amber  { color: var(--amber);  background: var(--amber-bg); }
        &--cyan   { color: var(--cyan);   background: var(--cyan-bg); }
        &--green  { color: var(--green);  background: var(--green-bg); }
        &--violet { color: var(--violet); background: var(--violet-bg); }
        &--accent { color: var(--accent-bright); background: var(--accent-bg); }
        &--gray   { color: var(--text-faint); background: var(--surface-3); }
    }

    // Severity dot (square, prototype .sev)
    .sec-dot {
        width: 8px;
        height: 8px;
        border-radius: $radius-badge;
        flex-shrink: 0;
        margin-top: $space-tight;
        background: var(--text-ghost);

        &--red   { background: var(--red); }
        &--amber { background: var(--amber); }
        &--cyan  { background: var(--cyan); }
        &--green { background: var(--green); }
    }

    // Key/value rows (consumes .sk-info-row)
    .sec-rows {
        .sk-info-row .v.sec-v-amber { color: var(--amber); }
    }

    // Left-aligned "what changed" chip cluster inside a table cell (FIM)
    .sec-what {
        display: inline-flex;
        flex-wrap: wrap;
        gap: $space-tight;
    }

    // Right-aligned chip cluster inside an info row (jail tags…)
    .sec-chiprow {
        display: flex;
        flex-wrap: wrap;
        justify-content: flex-end;
        gap: $space-tight;
    }

    // Findings / log rows (audit findings, lynis warnings + suggestions)
    .sec-finding-list {
        display: flex;
        flex-direction: column;
    }

    .sec-finding {
        display: flex;
        align-items: flex-start;
        gap: $space-3;
        padding: $space-2 0;
        border-top: 1px solid var(--border-soft);
        font-size: $text-sm;
        line-height: 1.45;

        &:first-child { border-top: none; }

        .sec-state { margin-top: 1px; }

        &__msg {
            flex: 1;
            min-width: 0;
            overflow-wrap: anywhere;
        }

        &--more {
            font-size: $text-xs;
            color: var(--text-faint);
        }
    }

    // Inline helpers
    .sec-mono {
        font-family: var(--mono);
        font-size: $text-xs;
        color: var(--text-dim);
    }

    .sec-faint { color: var(--text-faint); }
    .sk-dtable .sec-faint { color: var(--text-faint); }

    .sec-dash {
        color: var(--text-ghost);
    }

    .sk-dtable {
        .sec-ip--green { color: var(--green); }
        .sec-ip--red { color: var(--red); }

        .sec-path {
            max-width: 360px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            font-size: $text-xs;

            &--red { color: var(--red); }
        }

        .sec-proto {
            font-size: $text-xs;
        }

        .sec-rich-rule {
            font-size: $text-xs;
            word-break: break-all;
        }

        .sec-fp {
            font-size: $text-xs;
            word-break: break-all;
        }

        .sec-rowend { text-align: right; }
    }

    // Hint / note copy
    .sec-hint {
        margin: $space-4 0 0;
        font-size: $text-xs;
        line-height: 1.55;
        color: var(--text-faint);

        &--lead { margin: 0 0 $space-4; }
    }

    .sec-note {
        margin-top: $space-5;
        padding: $space-4;
        background: var(--surface-2);
        border: 1px solid var(--border-soft);
        border-radius: var(--radius-sm);
        font-size: $text-xs;
        color: var(--text-dim);

        p { margin: 0; line-height: 1.55; }
        strong { color: var(--text); }
    }

    // ── tab-root stacks (replaces ad-hoc margins) ───────────
    .scanner-tab,
    .quarantine-tab,
    .integrity-tab,
    .events-tab,
    .fail2ban-tab,
    .ssh-keys-tab,
    .ip-lists-tab,
    .audit-tab,
    .vulnerability-tab,
    .auto-updates-tab,
    .firewall-tab,
    .settings-tab {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: $space-4;

        > .alert { margin: 0; }
    }
}

// ── Overview tab ─────────────────────────────────────────────
.security-overview {
    display: flex;
    flex-direction: column;
    gap: $space-4;

    .sec-posture-card .card-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
    }

    // ── Posture header: ScoreGauge + verdict + live readouts ──
    .sec-posture__top {
        display: flex;
        align-items: center;
        gap: $space-6;
        padding-bottom: $space-4;
        margin-bottom: $space-2;
        border-bottom: 1px solid var(--border-soft);

        @media (max-width: $breakpoint-sm) {
            flex-direction: column;
            align-items: flex-start;
            gap: $space-4;
        }
    }

    .sec-posture__pending {
        display: grid;
        place-items: center;
        gap: $space-2;
        width: 104px;
        height: 104px;
        flex-shrink: 0;
        font-size: $text-xs;
        color: var(--text-faint);

        svg { color: var(--text-faint); }
    }

    .sec-posture__summary {
        flex: 1;
        min-width: 0;
    }

    .sec-posture__verdict {
        margin: 0 0 $space-3;
        font-size: $text-base;
        font-weight: $font-weight-semibold;
        color: var(--text);
    }

    // Live event readouts — relocated from the old page-wide KPI strip
    .sec-posture__kpis {
        display: flex;
        flex-wrap: wrap;
        gap: $space-2 $space-5;
    }

    .sec-kpi {
        display: grid;
        grid-template-columns: auto auto;
        grid-template-rows: auto auto;
        column-gap: $space-2;
        align-items: center;

        &__icon { grid-row: 1 / span 2; color: var(--text-faint); }

        &__val {
            font-size: $text-lg;
            font-weight: $font-weight-semibold;
            line-height: 1.1;
            letter-spacing: -0.02em;
            color: var(--text);

            &--text { font-size: $text-base; }
        }

        &__label {
            font-size: $text-xs;
            font-weight: $font-weight-semibold;
            color: var(--text-faint);
        }

        // Tone colors the numeral + glyph only (status, never decoration)
        &--amber { .sec-kpi__val, .sec-kpi__icon { color: var(--amber); } }
        &--red   { .sec-kpi__val, .sec-kpi__icon { color: var(--red); } }
        &--green .sec-kpi__icon { color: var(--green); }
        &--cyan  { .sec-kpi__val, .sec-kpi__icon { color: var(--cyan); } }
    }

    // ── Hardening checklist with inline one-click fixes ──
    .sec-posture__checks {
        display: flex;
        flex-direction: column;
    }

    .sec-posture__check {
        display: flex;
        align-items: center;
        gap: $space-3;
        min-height: 40px; // geometry: list-row height (40 default row)
        padding: $space-tight 0;
        border-top: 1px solid var(--border-soft);
        font-size: $text-sm;

        &:first-child { border-top: none; }

        &--pass    .sec-posture__ico { color: var(--green); }
        &--warn    .sec-posture__ico { color: var(--amber); }
        &--unknown .sec-posture__ico { color: var(--text-ghost); }
    }

    .sec-posture__ico { flex-shrink: 0; }

    .sec-posture__label {
        flex: 1;
        min-width: 0;
        color: var(--text);
    }

    .sec-posture__detail {
        font-size: $text-xs;
        color: var(--text-faint);
        white-space: nowrap;
    }

    // Trailing control column — buttons share a min width so the edge stays tidy
    .sec-posture__fix {
        flex-shrink: 0;
        min-width: 124px;
        justify-content: center;
    }

    .sec-posture__foot {
        margin-top: $space-4;
        padding-top: $space-4;
        border-top: 1px solid var(--border-soft);
    }

    // "Update definitions" sits inside the foot copy as a plain inline link
    .sec-posture__inline {
        height: auto;
        padding: 0;
        font-size: inherit;
        vertical-align: baseline;
    }
}

// Spinner for in-flight posture actions / pending score
.sec-spin { animation: sec-spin 0.8s linear infinite; }

@keyframes sec-spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
    .sec-spin { animation: none; }
}

// ── Scanner tab ──────────────────────────────────────────────
.scanner-tab {
    .scan-options {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: $space-4;

        @media (max-width: $breakpoint-lg) {
            grid-template-columns: repeat(2, 1fr);
        }

        @media (max-width: $breakpoint-md) {
            grid-template-columns: 1fr;
        }
    }

    .scan-card {
        display: flex;
        flex-direction: column;
        align-items: center;
        text-align: center;
        padding: $space-6 $space-4;
        background: var(--surface);
        border: 1px solid var(--border-soft);
        border-radius: var(--radius);
        cursor: pointer;
        transition: border-color 0.15s, transform 0.15s;

        &:hover {
            border-color: var(--border-strong);
            transform: translateY(-2px);
        }

        h4 {
            margin: 0 0 $space-1;
            font-size: $text-base;
            font-weight: $font-weight-semibold;
            color: var(--text);
        }

        .scan-desc {
            margin-bottom: $space-4;
            font-size: $text-xs;
            color: var(--text-faint);
        }

        > button { margin-top: auto; }
    }

    .scan-card-icon {
        display: grid;
        place-items: center;
        width: 38px;
        height: 38px; // geometry: icon tile
        margin-bottom: $space-3;
        border-radius: $radius-card;
        background: var(--surface-2);
        color: var(--text-dim);
    }

    .scan-card--quick .scan-card-icon { @include status-variant(var(--accent-bright), var(--accent-bg)); }
    .scan-card--full .scan-card-icon { @include status-variant(var(--violet), var(--violet-bg)); }
    .scan-card--custom .scan-card-icon { @include status-variant(var(--cyan), var(--cyan-bg)); }
    .scan-card--app .scan-card-icon { @include status-variant(var(--amber), var(--amber-bg)); }

    .scan-card--custom,
    .scan-card--app {
        cursor: default;

        &:hover {
            border-color: var(--border-soft);
            transform: none;
        }
    }

    .scan-custom-input {
        display: flex;
        gap: $space-2;
        width: 100%;
        margin-top: auto;

        input {
            flex: 1;
            min-width: 0;
        }
    }

    // App selector inside the "Scan an App" card — matches Input chrome
    .scan-app-select {
        flex: 1;
        min-width: 0;
        padding: 0 $space-2;
        height: $control-md;
        background: var(--surface-2);
        border: 1px solid var(--border-soft);
        border-radius: $radius-control;
        color: var(--text);
        font-size: $text-sm;

        &:focus {
            outline: none;
            border-color: var(--accent-dim);
        }
    }

    .scan-toolbar {
        display: flex;
        justify-content: flex-end;
        gap: $space-2;
    }

    // Findings table (YARA + ClamAV merged report)
    .scan-findings {
        border-color: rgba(240, 82, 82, 0.35);

        .scan-snippet {
            max-width: 260px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            font-size: $text-xs;
            color: var(--text-faint);
        }
    }

    // Web-shell rules manager card
    .yara-file-input { display: none; }

    .yara-custom-list {
        display: flex;
        flex-direction: column;
    }

    .yara-custom-item {
        display: flex;
        align-items: center;
        gap: $space-3;
        padding: $space-2 0;
        border-top: 1px solid var(--border-soft);

        &:first-child { border-top: none; }

        > .sec-mono:first-child { flex: 1; min-width: 0; }
    }
}

// Active-scan card (scanner + vulnerability tabs)
.scan-progress {
    .progress-info {
        display: flex;
        align-items: center;
        gap: $space-4;

        .spinner {
            width: 32px;
            height: 32px; // geometry: spinner icon
        }

        p {
            margin: 0;
            font-size: $text-sm;

            &:not(:last-child) {
                margin-bottom: $space-1;
            }
        }
    }
}

// ── Quarantine tab ───────────────────────────────────────────
.quarantine-tab {
    .empty-state svg { color: var(--green); }

    .quarantine-actions {
        display: flex;
        gap: $space-2;
    }
}

// ── Integrity tab ────────────────────────────────────────────
.integrity-tab {
    .description {
        margin-bottom: $space-5;
        font-size: $text-sm;
        line-height: 1.55;
        color: var(--text-dim);
    }

    .integrity-actions {
        display: flex;
        gap: $space-3;
    }

    // Change-kind chip column reads as a tag, not a full state wash
    .sk-dtable .sec-state { text-transform: lowercase; }
}

// ── Events tab ───────────────────────────────────────────────

// ── Settings tab ─────────────────────────────────────────────

// ── Firewall tab ─────────────────────────────────────────────
.firewall-tab {
    .firewall-status-row {
        display: flex;
        justify-content: space-between;
        align-items: center;
        flex-wrap: wrap;
        gap: $space-3;
        padding: $space-4 $space-5;
        background: var(--surface);
        border: 1px solid var(--border-soft);
        border-radius: var(--radius);
    }

    .status-indicator {
        display: flex;
        align-items: center;
        gap: $space-3;

        .sec-shield {
            display: grid;
            place-items: center;
            width: 32px;
            height: 32px; // geometry: icon tile
            border-radius: $radius-card;
            flex-shrink: 0;
        }

        &.active .sec-shield {
            @include status-variant(var(--green), var(--green-bg));
        }

        &.inactive .sec-shield {
            @include status-variant(var(--red), var(--red-bg));
        }

        &.unknown .sec-shield {
            @include status-variant(var(--amber), var(--amber-bg));
        }

        &__label {
            font-size: $text-sm;
            font-weight: $font-weight-semibold;
            color: var(--text);
        }

        .firewall-type {
            font-size: $text-xs;
            color: var(--text-faint);
        }
    }

    .firewall-actions {
        display: flex;
        flex-wrap: wrap;
        gap: $space-2;
    }

    .firewall-stats {
        display: flex;
        flex-wrap: wrap;
        gap: $space-3;
    }

    .stat-mini {
        display: flex;
        flex-direction: column;
        min-width: 120px;
        padding: $space-3 $space-4;
        background: var(--surface);
        border: 1px solid var(--border-soft);
        border-radius: var(--radius);

        .stat-value {
            font-size: $text-xl;
            font-weight: $font-weight-semibold;
            letter-spacing: -0.02em;
            line-height: 1.1;
        }

        .stat-label {
            margin-top: $space-tight;
            font-size: $text-xs;
            font-weight: $font-weight-semibold;
            color: var(--text-faint);
        }
    }

    .sec-subseg { align-self: flex-start; }

    .quick-ports-grid {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
        gap: $space-3;
    }

    .quick-port-card {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: $space-2;
        padding: $space-3 $space-4;
        background: var(--surface-2);
        border: 1px solid var(--border-soft);
        border-radius: var(--radius-sm);

        &.is-allowed {
            border-color: rgba(61, 220, 151, 0.3);
        }

        .port-info {
            display: flex;
            flex-direction: column;
            min-width: 0;

            .port-name {
                font-size: $text-sm;
                font-weight: $font-weight-medium;
            }

            .port-number {
                margin-top: $space-hair;
                font-family: var(--mono);
                font-size: $text-xs;
                color: var(--text-faint);
            }
        }
    }

    .blocked-list {
        display: flex;
        flex-direction: column;
    }

    .blocked-item {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: $space-3;
        padding: $space-3 $space-4;
        border-top: 1px solid var(--border-soft);

        .blocked-ip {
            font-family: var(--mono);
            font-size: $text-sm;
            font-weight: $font-weight-medium;
            color: var(--red);
        }
    }

    // (modal content portals to <body>; kept for parity with legacy markup)
    .install-info {
        margin-top: $space-4;
        padding: $space-4;
        background: var(--surface-2);
        border-radius: var(--radius-sm);

        p {
            margin: 0;
            font-size: $text-xs;
        }
    }
}

// ── IP Lists tab ─────────────────────────────────────────────
.ip-lists-tab {
    .ip-lists-grid {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
        gap: $space-4;
        align-items: start;

        @media (max-width: $breakpoint-sm) {
            grid-template-columns: 1fr;
        }
    }
}

// ── Audit tab ────────────────────────────────────────────────
.audit-tab {
    .loading-state {
        display: flex;
        flex-direction: column;
        align-items: center;
        padding: $space-8;
        gap: $space-4;

        .spinner {
            width: 40px;
            height: 40px; // geometry: spinner icon
        }
    }

    .audit-results {
        display: flex;
        flex-direction: column;
        gap: $space-5;
    }

    .sec-audit-score {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: $space-3;
        padding-top: $space-2;
    }

    .sec-audit-meta {
        font-size: $text-xs;
        color: var(--text-faint);
    }

    .audit-section {
        h4 {
            margin: 0 0 $space-2;
            padding-bottom: $space-2;
            border-bottom: 1px solid var(--border-soft);
            font-size: $text-xs;
            font-weight: $font-weight-semibold;
            color: var(--text-faint);
        }

        &.recommendations {
            padding: $space-4;
            background: var(--accent-bg-soft);
            border: 1px solid var(--accent-bg);
            border-radius: var(--radius-sm);

            h4 {
                border-bottom: none;
                padding-bottom: 0;
                color: var(--accent-bright);
            }

            ul {
                margin: 0;
                padding-left: $space-5;

                li {
                    margin-bottom: $space-2;
                    font-size: $text-sm;
                    line-height: 1.5;
                    color: var(--text-dim);

                    &:last-child {
                        margin-bottom: 0;
                    }
                }
            }
        }
    }
}

// ── Vulnerability tab ────────────────────────────────────────
.vulnerability-tab {
    .sec-hardening {
        display: flex;
        align-items: center;
        gap: $space-6;
        padding-bottom: $space-5;
        margin-bottom: $space-5;
        border-bottom: 1px solid var(--border-soft);

        &__title {
            font-size: $text-base;
            font-weight: $font-weight-semibold;
        }

        &__sub {
            margin-top: $space-tight;
            font-size: $text-xs;
            color: var(--text-faint);
        }
    }

    .scan-section {
        margin-bottom: $space-5;

        &:last-child { margin-bottom: 0; }

        h4 {
            margin: 0 0 $space-2;
            font-size: $text-xs;
            font-weight: $font-weight-semibold;
            color: var(--text-faint);
        }
    }
}

// ── Auto Updates tab ─────────────────────────────────────────
.auto-updates-tab {
    .auto-updates-actions {
        display: flex;
        gap: $space-3;
        margin-top: $space-5;
    }
}

// ============================================
// Shared (global) helpers — consumed by other pages too. Keep stable.
// ============================================
.not-installed {
    text-align: center;
    padding: $space-6;

    p {
        margin-bottom: $space-4;
        color: $text-secondary;
    }
}

.help-text {
    color: $text-secondary;
    font-size: $text-xs;
}

// Scrollable tabs for many tabs
.tabs-nav-scrollable {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: thin;

    &::-webkit-scrollbar {
        height: 4px;
    }

    &::-webkit-scrollbar-track {
        background: transparent;
    }

    &::-webkit-scrollbar-thumb {
        background: $border-subtle;
        border-radius: $radius-badge;
    }
}

// Fail2ban per-jail KPI cards
.fail2ban-tab {
    .f2b-jails {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: $space-3;
        margin-bottom: $space-4;
    }

    .f2b-jail {
        background: var(--surface);
        border: 1px solid var(--border-soft);
        border-radius: var(--radius);
        padding: $space-4 $space-4;

        &__name {
            display: flex;
            align-items: center;
            gap: $space-2;
            font-weight: $font-weight-semibold;
            font-size: $text-sm;
            margin-bottom: $space-3;

            svg { color: var(--accent-bright); }
        }

        &__stats {
            display: flex;
            gap: $space-5;
        }

        &__v {
            font-family: var(--mono);
            font-size: $text-lg;
            font-weight: $font-weight-semibold;

            &--amber { color: var(--amber); }
        }

        &__l {
            font-size: $text-xs;
            color: var(--text-faint);
            margin-top: $space-hair;
        }
    }
}