mirror of
https://github.com/Dvorinka/Containr.git
synced 2026-10-28 07:41:27 +00:00
feat(notifications): producers — backups, agent health, scans, upgrades (#49)
* feat(filters): dynamic filter framework — typed schema, URL state, FilterBar Port of dflow's filter.utils pattern, adapted to Containr: - lib/dynamic-filter.ts: FilterConfig schema (search/select/multiselect/ boolean/date-range/status), FilterEngine with client-side apply, derived options with counts, active-filter tracking, removal. - lib/use-dynamic-filter.ts: filter state lives in ?f.<key> search params — filtered views are shareable links. useFilterState exposes URL state before data loads (server-backed filters); useDynamicFilter adds the engine over fetched data. - shared/components/FilterBar.tsx: renders a schema as compact controls + active-filter chips, matching design tokens. - Applied: audit logs (server-backed — state in URL, params to API), builds (server-backed + client date-range), activity (severity to the server query, category/search on the fetched page). - 8 unit tests for the engine. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fix(filters): erasableSyntaxOnly compat + BuildStatus cast - Constructor parameter properties are banned under erasableSyntaxOnly — declare fields explicitly. - listBuilds status param needs the BuildStatus type, not raw string. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> * feat(notifications): producers round-out — backups, agent health, scans, upgrades Four new emitters behind insertUserNotification: - Backups: createBackupProcess notifies the database owner on completion (with size) and on failure (docker-down, snapshot error). - Agent health: StartAgentHealthSweep marks agents offline after 3 min without heartbeat and back online on recovery — admins notified on each transition. - Security scans: Scanner.OnScanComplete callback notifies the project owner with critical/high/total counts + score; scans with findings get a distinct title. - Upgrades: daily check against the latest GitHub release; admins notified once per new tag (deduped via app_settings). Version stamped into the image via Dockerfile ARG + ldflags on tag builds; "dev" disables the check. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> --------- Co-authored-by: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
d4a4cde1fd
commit
7547375cc2
8 files changed
+289
-3
No files matched your search
@@ -29,9 +29,27 @@ type SecurityHandler struct {
|
||||
func NewSecurityHandler(db *database.DB, encryptionKey string) *SecurityHandler {
|
||||
encryptionManager, _ := security.NewEncryptionManager(encryptionKey)
|
||||
|
||||
scanner := security.NewScanner(db)
|
||||
// Notify the project owner when a background scan completes — criticals
|
||||
// earn a distinct title so they stand out in the notification list.
|
||||
scanner.OnScanComplete = func(scan *security.SecurityScan) {
|
||||
var ownerID string
|
||||
if err := db.QueryRow(`SELECT owner_id::text FROM projects WHERE id = $1`, scan.ProjectID).Scan(&ownerID); err != nil || ownerID == "" {
|
||||
return
|
||||
}
|
||||
title := "Security scan completed"
|
||||
if scan.Summary.Critical > 0 || scan.Summary.High > 0 {
|
||||
title = "Security scan found issues"
|
||||
}
|
||||
insertUserNotification(db, ownerID, "security", title,
|
||||
fmt.Sprintf("%s scan finished: %d critical, %d high, %d total findings (score %d/100).",
|
||||
scan.ScanType, scan.Summary.Critical, scan.Summary.High, scan.Summary.Total, scan.Summary.Score),
|
||||
"project", scan.ProjectID)
|
||||
}
|
||||
|
||||
return &SecurityHandler{
|
||||
db: db,
|
||||
scanner: security.NewScanner(db),
|
||||
scanner: scanner,
|
||||
complianceManager: security.NewComplianceManager(db),
|
||||
encryptionManager: encryptionManager,
|
||||
dataRetentionManager: security.NewDataRetentionManager(encryptionManager),
|
||||
|
||||
Reference in new issue
Block a user