Documentation
¶
Overview ¶
Package reports is the reports module (S-REP-1, S-REP-2, modules/reports/CONTRACT.md): the one-page weekly report, sent by email on a schedule through notify, and the personal-data-protection self-assessment under Law 91/2025/QH15 and Decree 356/2025/NĐ-CP. PDF is made by the browser from the print pages; the server renders no PDF and no HTML.
Index ¶
- Constants
- Variables
- func FlowLine(s ReportSummary) string
- func HandledLine(h Handled, software string, loc *time.Location) string
- func ItemLine(it HandledItem, loc *time.Location) string
- func Jobs(svc *Service) []jobs.Job
- func Regime(o PdplOrg) string
- func ScheduleKey(id string) string
- type AI
- type AiSummary
- type Block
- type Config
- type Coverage
- type CveSeverity
- type Definition
- type DefinitionInput
- type Detection
- type DetectionCount
- type Detections
- type Device
- type DeviceRef
- type DocPeriod
- type Document
- type Exposure
- type ExposureIssues
- type ExposureService
- type ExposureTarget
- type FeedHealth
- type FeedState
- type Feeds
- type Finding
- type FindingEvent
- type FindingRow
- type FindingView
- type FindingViews
- type Findings
- type FirstThing
- type Fix
- type Handled
- type HandledDevice
- type HandledItem
- type HandledTotal
- type Inventory
- type KEV
- type KEVEntry
- type KeySystem
- type KindCount
- type KindCountAt
- type Mail
- type Mailer
- type Measure
- type Modules
- type Obligation
- type OpenGroup
- type Options
- type PdplDefaults
- type PdplInventory
- type PdplOrg
- type PdplReport
- type PdplState
- type PdplView
- type Reason
- type ReportCoverage
- type ReportDetections
- type ReportExposure
- type ReportFinding
- type ReportHandled
- type ReportNew
- type ReportOpen
- type ReportSummary
- type ReportsHandlers
- func (h *ReportsHandlers) ReportsGetReportsDefinition(ctx context.Context) (*oas.ReportsGetReportsDefinitionOK, error)
- func (h *ReportsHandlers) ReportsGetReportsDocument(ctx context.Context) (*oas.ReportsGetReportsDocumentOK, error)
- func (h *ReportsHandlers) ReportsGetReportsHistory(ctx context.Context) (*oas.ReportsGetReportsHistoryOK, error)
- func (h *ReportsHandlers) ReportsGetReportsHistoryID(ctx context.Context, params oas.ReportsGetReportsHistoryIDParams) (*oas.ReportsGetReportsHistoryIDOK, error)
- func (h *ReportsHandlers) ReportsGetReportsPdpl(ctx context.Context) (*oas.ReportsGetReportsPdplOK, error)
- func (h *ReportsHandlers) ReportsPostReportsPdplAiSummary(ctx context.Context) (*oas.ReportsPostReportsPdplAiSummaryOK, error)
- func (h *ReportsHandlers) ReportsPostReportsPdplGenerate(ctx context.Context) (*oas.ReportsPostReportsPdplGenerateOK, error)
- func (h *ReportsHandlers) ReportsPostReportsSend(ctx context.Context) (*oas.ReportsPostReportsSendOK, error)
- func (h *ReportsHandlers) ReportsPutReportsDefinition(ctx context.Context, req *oas.ReportsPutReportsDefinitionReq) (*oas.ReportsPutReportsDefinitionOK, error)
- func (h *ReportsHandlers) ReportsPutReportsPdplOrg(ctx context.Context, req *oas.ReportsPutReportsPdplOrgReq) (*oas.ReportsPutReportsPdplOrgOK, error)
- type Sections
- type SentItem
- type SentPeriod
- type SentReport
- type Service
- func (s *Service) Definition(ctx context.Context) (Definition, error)
- func (s *Service) Document(ctx context.Context) (Document, error)
- func (s *Service) GeneratePdpl(ctx context.Context, actor string) (PdplReport, error)
- func (s *Service) History(ctx context.Context) ([]SentItem, error)
- func (s *Service) Pdpl(ctx context.Context) (PdplState, error)
- func (s *Service) PdplAI(ctx context.Context, actor string) (AiSummary, error)
- func (s *Service) RunPending(ctx context.Context) error
- func (s *Service) SaveDefinition(ctx context.Context, actor string, in DefinitionInput) (Definition, error)
- func (s *Service) SavePdplOrg(ctx context.Context, actor string, in PdplOrg) (PdplOrg, error)
- func (s *Service) ScheduleOwner() schedule.Owner
- func (s *Service) SendNow(ctx context.Context, actor string) (SentItem, error)
- func (s *Service) Sent(ctx context.Context, id string) (SentReport, error)
- type SourceCount
- type SourceOn
- type StatusCount
- type Summary
- type Tokens
- type TopDetection
- type Verification
Constants ¶
const ( PeriodLast7 = "last_7_days" PeriodLast30 = "last_30_days" PeriodMonth = "calendar_month" // the last whole calendar month in the organisation's time zone )
The periods a report covers.
const DefinitionID = "security"
DefinitionID is the id of the one report definition (a single template with section switches; SPEC: no template choice).
const JobTick = 20 * time.Second
JobTick is how often the send job looks for a send the schedule asked for; nearly every wake-up reads one row and does nothing.
const MaxHistory = 52
MaxHistory is how many sent reports are kept; older ones are removed when a new one is recorded.
const MaxRecipients = 20
MaxRecipients is the longest recipient list (INV-3).
const MaxRows = 100
MaxRows caps each list of a document. The counts are of everything; a report of a very large estate stays bounded.
const ModuleID = "reports"
ModuleID is the id of this module in MANIFEST.yaml.
const ScheduleOwnerKey = "reports.def"
ScheduleOwnerKey is the owner key prefix of the report's schedule in core/schedule: reports.def:<definition id>.
Variables ¶
var DefaultOptions = Options{Period: PeriodLast7, Grouping: "device", IncludeNotAdded: true, IncludeNotRelevant: false, Charts: true, Sections: Sections{Summary: true, Handled: true, Open: true, New: true, Exposure: true, Detections: true, Coverage: true}}
DefaultOptions is the report before anyone saves it: the last 7 days, every section, devices not added yet in, not relevant out.
var Migrations = mustSub(migrationFiles, "migrations/sqlite")
Migrations holds the SQLite migrations of the reports module, rooted at the directory that holds the NNNN_*.sql files. Apply them after core's: store.Migrate(ctx, db, "reports", reports.Migrations).
Functions ¶
func FlowLine ¶
func FlowLine(s ReportSummary) string
FlowLine is how the open findings moved through the period, in the order the page's chart draws it, so the figures add up: "Open at the start: 0. New: 892. Handled: 11. Reopened: 4. Open now: 885." A change no count names (a finding left out since the start) is "Other changes".
func HandledLine ¶
HandledLine is who handled a finding and how, from the stored fields, in the words the pages use: "Patched by Vedette: version moved 6.24 → 7.23 (18 Nov 2026)", "Patched by Vedette: WinRAR was removed (18 Nov 2026)", "Mitigated by ana@example.com (17 Nov 2026): firewall rule", "Risk accepted until 24 Dec 2026 by ana@example.com (17 Nov 2026)". The day is written in loc, the organisation's zone.
func ItemLine ¶
func ItemLine(it HandledItem, loc *time.Location) string
ItemLine is HandledLine of a finding the period lists as handled, with the day it opened again when it is open at the period's end ("…: open again since 24 Nov 2026"), so a reader does not take a reopened finding for one that is done.
func Jobs ¶
Jobs returns the jobs of the module; core runs them only while the module is on (SYS-5).
func Regime ¶
Regime is how the impact-assessment and data-protection-officer duties apply to the organisation (INV-6): required, optional or exempt. It is computed, never decided by the AI.
func ScheduleKey ¶
ScheduleKey is the core/schedule owner key of a definition's schedule.
Types ¶
type AI ¶
type AI interface {
Available(job string) bool
Summarize(ctx context.Context, actor, job, task string, data []Block) (Summary, error)
}
AI asks the ai module for a commentary. Job is "pdpl-assessment". Errors that a person should see are *apierr.Error.
type AiSummary ¶
type AiSummary struct {
Paragraphs []string `json:"paragraphs"`
Model string `json:"model"`
Profile string `json:"profile,omitempty"`
Tokens Tokens `json:"tokens"`
GeneratedAt string `json:"generated_at"`
}
AiSummary is the AI commentary. It is always shown as "AI generated" and never changes a figure (INV-5).
type Block ¶
type Block struct{ Source, Text string }
Block is a piece of data given to the AI, fenced there as untrusted.
type Config ¶
type Config struct {
DB *store.DB
Audit *audit.Log
Inventory Inventory
Findings Findings // the PDPL assessment's risks
Views FindingViews // the periodic report's findings
KEV KEV
Exposure Exposure // without it the External exposure section says the module is off
Detections Detections // without it the Detections section says detection is off
Feeds Feeds // without it Coverage lists no feed
Mail Mailer
AI AI
Modules Modules
OrgName func(context.Context) (string, error)
Zone func(context.Context) string // IANA name of the organisation's time zone; "" or an unknown name = UTC
// Every is how often the report's schedule sends it ("weekly", "monthly") while it is on, "" while it is off or unknown: a sent
// report covers the time since the one before it, so the schedule decides the period (periodFollows).
Every func(context.Context) string
Log *slog.Logger
Clock func() time.Time
}
Config is what NewService needs. Exposure, Detections, Feeds, Mail, AI, Modules, OrgName, Zone and Clock may be nil.
type CveSeverity ¶
type CveSeverity struct {
Band string `json:"band"`
Score float64 `json:"score"`
Version string `json:"version"`
Vector string `json:"vector"`
}
CveSeverity is the CVSS base score of a CVE and its band (findings contract). nil = "Not scored yet".
type Definition ¶
type Definition struct {
ID string `json:"id"`
Name string `json:"name"`
Options Options `json:"options"`
Recipients []string `json:"recipients"`
ScheduleKey string `json:"schedule_key"`
UpdatedAt string `json:"updated_at"`
UpdatedBy string `json:"updated_by"`
}
Definition is the one report: its name, options and recipients, and the key of its schedule in core/schedule.
type DefinitionInput ¶
type DefinitionInput struct {
Name string `json:"name"`
Options Options `json:"options"`
Recipients []string `json:"recipients"`
}
DefinitionInput is the body of PUT /reports/definition.
type Detection ¶
type Detection struct {
Kind, Title, Severity string
DeviceID, DeviceName string
Devices int // how many devices it names; DeviceID is the first
At time.Time
}
Detection is one incident of the period that matters: its kind, title, severity and device (DeviceID "" = none).
type DetectionCount ¶
DetectionCount is how many incidents of a kind had activity in the period, and when the newest was.
type Detections ¶
type Detections interface {
Period(ctx context.Context, from, to time.Time, top int) ([]DetectionCount, []Detection, error)
}
Detections reads the incidents with activity in the period (notify): every kind counted whole, and the top few by severity then recency.
type Device ¶
type Device struct {
ID string
Name string // hostname, else the IP
IP string
Kind string
OS string // "" = unknown
Approved bool // false = "Not added yet"
Fragile bool
Ports []int // open TCP/UDP service ports
Box bool // this Vedette box: counted like the Devices page counts it; not in the PDPL inventory
Agent bool // an agent on the device reports its software (osquery, Wazuh, the box's own host agent)
Sources []string // the source of each of vendor, model and OS that is known
}
Device is a device as the reports need it. The list leaves out the devices a person ignored.
type DocPeriod ¶
type DocPeriod struct {
Kind string `json:"kind"`
From string `json:"from"`
To string `json:"to"`
TZ string `json:"tz"`
}
DocPeriod is the time a document covers, in the zone it was read in.
type Document ¶
type Document struct {
DefinitionID string `json:"definition_id"`
Title string `json:"title"`
GeneratedAt string `json:"generated_at"`
Org string `json:"org"`
Period DocPeriod `json:"period"`
Options Options `json:"options"`
Summary *ReportSummary `json:"summary,omitempty"`
Handled *ReportHandled `json:"handled,omitempty"`
Open *ReportOpen `json:"open,omitempty"`
New *ReportNew `json:"new,omitempty"`
Exposure *ReportExposure `json:"exposure,omitempty"`
Detections *ReportDetections `json:"detections,omitempty"`
Coverage *ReportCoverage `json:"coverage,omitempty"`
AISummary *AiSummary `json:"ai_summary"`
}
Document is the report as made at GeneratedAt; a section switched off is absent.
type Exposure ¶
type Exposure interface {
Targets(ctx context.Context, from, to time.Time) ([]ExposureTarget, error)
}
Exposure reads every external exposure target as the report's section shows it, with the changes inside the period.
type ExposureIssues ¶
type ExposureIssues struct {
Engine string `json:"engine"`
Severity string `json:"severity"`
Open int `json:"open"`
New int `json:"new"`
}
ExposureIssues counts the open issues of one engine and severity, and how many of them are new in the period.
type ExposureService ¶
type ExposureService struct {
IP string `json:"ip"`
Port int `json:"port"`
Proto string `json:"proto"`
Name *string `json:"name"`
Product *string `json:"product"`
Version *string `json:"version"`
Change *string `json:"change"`
CertExpiresAt *string `json:"cert_expires_at"`
}
ExposureService is an open port of a target, or one closed in the period.
type ExposureTarget ¶
type ExposureTarget struct {
TargetID string `json:"target_id"`
Kind string `json:"kind"`
Value string `json:"value"`
Parent *string `json:"parent"`
Proof string `json:"proof"`
LastScanAt *string `json:"last_scan_at"`
Services []ExposureService `json:"services"`
Issues []ExposureIssues `json:"issues"`
}
ExposureTarget is one external exposure target.
type FeedHealth ¶
FeedHealth is one enabled vulnerability feed: when it last loaded and whether that is older than its schedule allows.
type FeedState ¶
type FeedState struct {
ID string `json:"id"`
Name string `json:"name"`
LastOKAt *string `json:"last_ok_at"`
Stale bool `json:"stale"`
}
FeedState is one vulnerability feed's health.
type Feeds ¶
type Feeds interface {
Health(ctx context.Context) ([]FeedHealth, error)
}
Feeds reads the health of the vulnerability feeds.
type Finding ¶
type Finding struct {
ID, AssetID, CVE string
Status, Severity string
FirstSeen time.Time
Agent bool // the version compared is the one the device's own agent reports
}
Finding is an open finding as the PDPL assessment reads it. Status is confirmed (a scan or a person confirmed it) or suspected: handled findings never arrive. Severity is one of critical, high, medium, low, info.
type FindingEvent ¶
type FindingEvent struct {
At time.Time
Kind string // created, handled, reopened, acceptance_expired
Handled *Handled
}
FindingEvent is one change of a finding's state (fnd_finding_event). Handled is set on a handled event: who and how, from the event's stored fields, so the report says how it was handled at that time even when it was handled again since.
type FindingRow ¶
type FindingRow struct {
ID string `json:"id"`
CVE string `json:"cve"`
Device string `json:"device"`
AssetID string `json:"asset_id"`
Product string `json:"product"`
Status string `json:"status"`
Severity string `json:"severity"`
Since string `json:"since"`
Agent bool `json:"agent,omitempty"` // the device's own agent reported the version compared: "Detected by the agent", not "Suspected"
// DeviceApproved is false when the device is still to review (inventory not approved), so not in the Devices list yet. A finding
// whose device inventory does not know counts as approved.
DeviceApproved bool `json:"device_approved"`
}
FindingRow is one finding as the PDPL assessment lists it.
type FindingView ¶
type FindingView struct {
ID, CVE string
Device DeviceRef
Product string // the software line, as Findings names it ("" = the fix's product)
Version string // the version the finding was matched on ("" = none)
Status string // the one status now (findings.StatusOf): an open code, or the resolution once handled
Urgency int // the stored layer, 1 to 5
Severity *CveSeverity
Verification Verification
Fix Fix
Handled *Handled // the handling now; nil while open
FirstSeen time.Time
Events []FindingEvent // oldest first: created, handled, reopened, acceptance_expired
}
FindingView is a finding as findings.View shows it on every page, with the events that changed its state. The shapes are the findings contract's, so the document carries the same status, severity, verification, fix and handled line as the Findings page.
type FindingViews ¶
type FindingViews interface {
Views(ctx context.Context) ([]FindingView, error)
Reasons(ctx context.Context, ids []string) (map[string][]Reason, error)
}
FindingViews reads the findings of the watched devices (a device a person ignored is left out, as on every findings list) and the urgency reasons of the few the document lists.
type FirstThing ¶
type FirstThing struct {
Status string `json:"status"`
CVE string `json:"cve"`
FindingID string `json:"finding_id"`
Product string `json:"product"`
Severity *CveSeverity `json:"severity"`
Fix Fix `json:"fix"`
Devices []DeviceRef `json:"devices"`
DeviceCount int `json:"device_count"`
FindingCount int `json:"finding_count"`
}
FirstThing is one of the three things to do first: one CVE on one product, most urgent first.
type Fix ¶
type Fix struct {
Key string `json:"key"`
Kind string `json:"kind"`
Product string `json:"product"`
Version *string `json:"version"`
Ref *string `json:"ref"`
URL *string `json:"url"`
}
Fix is what fixes a finding (findings contract).
type Handled ¶
type Handled struct {
Resolution string `json:"resolution"`
Via string `json:"via"`
By string `json:"by"`
At string `json:"at"`
Note *string `json:"note"`
AcceptedUntil *string `json:"accepted_until"`
FromVersion *string `json:"from_version"`
ToVersion *string `json:"to_version"`
}
Handled is who handled a finding and how, from stored fields (findings contract): "Patched by Vedette: version moved 6.24 → 7.23". By is "system" when Vedette handled it.
type HandledDevice ¶
type HandledDevice struct {
Device DeviceRef `json:"device"`
Items []HandledItem `json:"items"`
}
HandledDevice is the findings of one device handled in the period.
type HandledItem ¶
type HandledItem struct {
FindingID string `json:"finding_id"`
CVE string `json:"cve"`
Product string `json:"product"`
Severity *CveSeverity `json:"severity"`
Handled Handled `json:"handled"`
// ReopenedAt: the finding opened again after this handling, inside the period, and is open at its end (it is in Still open too).
// Absent otherwise, and in documents sent before it existed.
ReopenedAt *string `json:"reopened_at,omitempty"`
}
HandledItem is one finding handled in the period.
type HandledTotal ¶
type HandledTotal struct {
Resolution string `json:"resolution"`
Via string `json:"via"`
N int `json:"n"`
}
HandledTotal is how many findings were handled one way.
type KEVEntry ¶
type KEVEntry struct {
CVE, Vendor, Product string
Display string // the product name Findings shows (feeds.DisplayOf); "" = "<vendor> <product>"
}
KEVEntry is one entry of the exploited-vulnerability list (the PDPL risks name a finding's product by it).
type KeySystem ¶
type KeySystem struct {
ID string `json:"id"`
Name string `json:"name"`
IP string `json:"ip"`
Kind string `json:"kind"`
OS string `json:"os"`
}
KeySystem is a server, NAS or firewall.
type KindCountAt ¶
type KindCountAt struct {
Kind string `json:"kind"`
N int `json:"n"`
LastAt string `json:"last_at"`
}
KindCountAt is how many incidents of a kind, and the newest.
type Mailer ¶
type Mailer interface {
Ready(ctx context.Context) (ok bool, reason string)
Send(ctx context.Context, to []string, m Mail) error
}
Mailer sends through the email channel of notify (INV-4). Ready says whether it can now and, when it cannot, why in a sentence for a person.
type Measure ¶
type Measure struct {
ID string `json:"id"`
Status string `json:"status"`
N int `json:"n"`
Names []string `json:"names"`
}
Measure is one technical measure the box can see (INV-8). Status is ok, attention or unknown; n counts what it found and names lists the first few.
type Obligation ¶
type Obligation struct {
ID string `json:"id"`
Applies bool `json:"applies"`
Regime string `json:"regime"`
Done *bool `json:"done"`
}
Obligation is one duty of the law (INV-6). Done is null when the box cannot know.
type OpenGroup ¶
type OpenGroup struct {
Key string `json:"key"`
Label string `json:"label"`
Status string `json:"status"`
Items []ReportFinding `json:"items"`
// Total is every open finding of the group, listed or not (a report lists 100 rows at most): the header says "70 of 147 shown".
// Absent in a report sent before it was counted (a group always has one), so the page counts the listed rows there.
Total int `json:"total,omitempty"`
}
OpenGroup is one device or one CVE of Still open.
type Options ¶
type Options struct {
Period string `json:"period"`
Grouping string `json:"grouping"`
IncludeNotAdded bool `json:"include_not_added"`
IncludeNotRelevant bool `json:"include_not_relevant"`
Sections Sections `json:"sections"`
Charts bool `json:"charts"`
}
Options are what the document is made with. Period is last_7_days, last_30_days or calendar_month; Grouping device or cve.
type PdplDefaults ¶
type PdplDefaults struct {
Name string `json:"name"`
}
PdplDefaults are values the form starts with.
type PdplInventory ¶
type PdplInventory struct {
Total int `json:"total"`
Approved int `json:"approved"`
Unapproved int `json:"unapproved"`
Fragile int `json:"fragile"`
ByKind []KindCount `json:"by_kind"`
KeySystems []KeySystem `json:"key_systems"`
Sources []SourceCount `json:"sources"`
}
PdplInventory is the device picture of the assessment.
type PdplOrg ¶
type PdplOrg struct {
Name string `json:"name"`
TaxCode string `json:"tax_code"`
Address string `json:"address"`
Sector string `json:"sector"`
Employees int `json:"employees"`
DataVolume string `json:"data_volume"`
Size string `json:"size"`
ProcessingService bool `json:"processing_service"`
ContactName string `json:"contact_name"`
ContactEmail string `json:"contact_email"`
ContactPhone string `json:"contact_phone"`
Sensitive bool `json:"sensitive"`
CrossBorder bool `json:"cross_border"`
Processors bool `json:"processors"`
Level string `json:"level"`
}
PdplOrg is what the organisation tells the assessment about itself.
type PdplReport ¶
type PdplReport struct {
ID string `json:"id"`
GeneratedAt string `json:"generated_at"`
Org PdplOrg `json:"org"`
Inventory PdplInventory `json:"inventory"`
Measures []Measure `json:"measures"`
Risks []FindingRow `json:"risks"`
Obligations []Obligation `json:"obligations"`
Coverage []Coverage `json:"coverage"`
AISummary *AiSummary `json:"ai_summary"`
// ApprovedOnly is the inventory, measures and risks without the devices not approved yet and their findings; nil in reports
// generated before it.
ApprovedOnly *PdplView `json:"approved_only,omitempty"`
}
PdplReport is the generated self-assessment.
type PdplState ¶
type PdplState struct {
Org *PdplOrg `json:"org"`
Defaults PdplDefaults `json:"defaults"`
Report *PdplReport `json:"report"`
AIAvailable bool `json:"ai_available"`
}
PdplState is GET /reports/pdpl.
type PdplView ¶
type PdplView struct {
Inventory PdplInventory `json:"inventory"`
Measures []Measure `json:"measures"`
Risks []FindingRow `json:"risks"`
}
PdplView is the part of the assessment that changes when the devices not approved yet are left out. Its "unapproved" measure is the full report's: leaving those devices out of the view does not approve them.
type Reason ¶
type Reason struct {
Layer int `json:"layer"`
Source string `json:"source"`
Name string `json:"name"`
Date string `json:"date"`
URL *string `json:"url"`
Detail *string `json:"detail"`
Due *string `json:"due"`
}
Reason is one urgency layer of 1 to 4 that applies, with its evidence (findings contract).
type ReportCoverage ¶
type ReportCoverage struct {
Devices int `json:"devices"`
WithAgent int `json:"with_agent"`
NotAdded int `json:"not_added"`
Sources []SourceOn `json:"sources"`
Feeds []FeedState `json:"feeds"`
}
ReportCoverage is section 7: what Vedette can and cannot see.
type ReportDetections ¶
type ReportDetections struct {
ModuleOn bool `json:"module_on"`
ByKind []KindCountAt `json:"by_kind"`
Top []TopDetection `json:"top"`
}
ReportDetections is section 6.
type ReportExposure ¶
type ReportExposure struct {
ModuleOn bool `json:"module_on"`
Targets []ExposureTarget `json:"targets"`
}
ReportExposure is section 5.
type ReportFinding ¶
type ReportFinding struct {
FindingID string `json:"finding_id"`
CVE string `json:"cve"`
Device DeviceRef `json:"device"`
Product string `json:"product"`
Version *string `json:"version"`
Status string `json:"status"`
Reasons []Reason `json:"reasons"`
Severity *CveSeverity `json:"severity"`
Verification Verification `json:"verification"`
Fix Fix `json:"fix"`
FirstSeen string `json:"first_seen"`
}
ReportFinding is one finding as the document lists it.
type ReportHandled ¶
type ReportHandled struct {
Totals []HandledTotal `json:"totals"`
Devices []HandledDevice `json:"devices"`
More int `json:"more"`
MedianDays *float64 `json:"median_days"`
// NotRelevantLeftOut: findings closed as not relevant in the period that the report leaves out ("Include not relevant" off), so
// the report says why its count is lower than Findings › Handled. Absent in documents sent before it existed.
NotRelevantLeftOut int `json:"not_relevant_left_out,omitempty"`
}
ReportHandled is section 2: the proof of what was done.
type ReportNew ¶
type ReportNew struct {
Total int `json:"total"`
Open int `json:"open,omitempty"` // of Total, still open at the end of the period, listed or not; absent when none or sent before
Items []ReportFinding `json:"items"`
More int `json:"more"`
}
ReportNew is section 4.
type ReportOpen ¶
type ReportOpen struct {
Grouping string `json:"grouping"`
Total int `json:"total"`
Groups []OpenGroup `json:"groups"`
More int `json:"more"`
}
ReportOpen is section 3.
type ReportSummary ¶
type ReportSummary struct {
OpenByStatus []StatusCount `json:"open_by_status"`
OpenNow int `json:"open_now"`
OpenBefore int `json:"open_before"`
New int `json:"new"`
Handled int `json:"handled"`
// Reopened: findings open at the end that opened again in the period after a handling (handled in the period, or before it), so
// open_now = open_before + new - handled + reopened. Absent when none, and in documents sent before it existed.
Reopened int `json:"reopened,omitempty"`
First []FirstThing `json:"first"`
}
ReportSummary is section 1.
type ReportsHandlers ¶
type ReportsHandlers struct {
// contains filtered or unexported fields
}
ReportsHandlers implements the reports operations (modules/reports/CONTRACT.md). Embed it in the composite handler. Roles are enforced by the server pipeline before a handler runs, never here.
func NewReportsHandlers ¶
func NewReportsHandlers(svc *Service) *ReportsHandlers
NewReportsHandlers returns the handlers of svc.
func (*ReportsHandlers) ReportsGetReportsDefinition ¶
func (h *ReportsHandlers) ReportsGetReportsDefinition(ctx context.Context) (*oas.ReportsGetReportsDefinitionOK, error)
ReportsGetReportsDefinition implements reports_get_reports_definition.
func (*ReportsHandlers) ReportsGetReportsDocument ¶
func (h *ReportsHandlers) ReportsGetReportsDocument(ctx context.Context) (*oas.ReportsGetReportsDocumentOK, error)
ReportsGetReportsDocument implements reports_get_reports_document.
func (*ReportsHandlers) ReportsGetReportsHistory ¶
func (h *ReportsHandlers) ReportsGetReportsHistory(ctx context.Context) (*oas.ReportsGetReportsHistoryOK, error)
ReportsGetReportsHistory implements reports_get_reports_history.
func (*ReportsHandlers) ReportsGetReportsHistoryID ¶
func (h *ReportsHandlers) ReportsGetReportsHistoryID(ctx context.Context, params oas.ReportsGetReportsHistoryIDParams) (*oas.ReportsGetReportsHistoryIDOK, error)
ReportsGetReportsHistoryID implements reports_get_reports_history_id.
func (*ReportsHandlers) ReportsGetReportsPdpl ¶
func (h *ReportsHandlers) ReportsGetReportsPdpl(ctx context.Context) (*oas.ReportsGetReportsPdplOK, error)
ReportsGetReportsPdpl implements reports_get_reports_pdpl.
func (*ReportsHandlers) ReportsPostReportsPdplAiSummary ¶
func (h *ReportsHandlers) ReportsPostReportsPdplAiSummary(ctx context.Context) (*oas.ReportsPostReportsPdplAiSummaryOK, error)
ReportsPostReportsPdplAiSummary implements reports_post_reports_pdpl_ai_summary (operator).
func (*ReportsHandlers) ReportsPostReportsPdplGenerate ¶
func (h *ReportsHandlers) ReportsPostReportsPdplGenerate(ctx context.Context) (*oas.ReportsPostReportsPdplGenerateOK, error)
ReportsPostReportsPdplGenerate implements reports_post_reports_pdpl_generate (operator).
func (*ReportsHandlers) ReportsPostReportsSend ¶
func (h *ReportsHandlers) ReportsPostReportsSend(ctx context.Context) (*oas.ReportsPostReportsSendOK, error)
ReportsPostReportsSend implements reports_post_reports_send (operator).
func (*ReportsHandlers) ReportsPutReportsDefinition ¶
func (h *ReportsHandlers) ReportsPutReportsDefinition(ctx context.Context, req *oas.ReportsPutReportsDefinitionReq) (*oas.ReportsPutReportsDefinitionOK, error)
ReportsPutReportsDefinition implements reports_put_reports_definition (admin).
func (*ReportsHandlers) ReportsPutReportsPdplOrg ¶
func (h *ReportsHandlers) ReportsPutReportsPdplOrg(ctx context.Context, req *oas.ReportsPutReportsPdplOrgReq) (*oas.ReportsPutReportsPdplOrgOK, error)
ReportsPutReportsPdplOrg implements reports_put_reports_pdpl_org (operator).
type Sections ¶
type Sections struct {
Summary bool `json:"summary"`
Handled bool `json:"handled"`
Open bool `json:"open"`
New bool `json:"new"`
Exposure bool `json:"exposure"`
Detections bool `json:"detections"`
Coverage bool `json:"coverage"`
}
Sections are the section switches of the report.
type SentItem ¶
type SentItem struct {
ID string `json:"id"`
DefinitionID string `json:"definition_id"`
Title string `json:"title"`
SentAt string `json:"sent_at"`
Period SentPeriod `json:"period"`
Trigger string `json:"trigger"`
Recipients []string `json:"recipients"`
Status string `json:"status"`
Error *string `json:"error"`
SentBy *string `json:"sent_by"`
}
SentItem is one send attempt, as the History tab lists it.
type SentPeriod ¶
SentPeriod is the period of a sent report.
type SentReport ¶
SentReport is a send attempt with the document exactly as it was sent (INV-2).
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service owns the rep_ tables. Every mutation runs in one transaction with its core_audit row (SYS-3).
func NewService ¶
NewService returns the service. DB, Audit, Inventory, Findings, Views, KEV and Log are required.
func (*Service) Definition ¶
func (s *Service) Definition(ctx context.Context) (Definition, error)
Definition is GET /reports/definition.
func (*Service) Document ¶
Document is GET /reports/document: the report of the current period, made now with the saved definition (INV-1). Each section reads its own source; a source that cannot be read fails the document rather than show a section that is not true.
func (*Service) GeneratePdpl ¶
GeneratePdpl is POST /reports/pdpl/generate (PRE-3, POST-3). A new report replaces the old one, with its AI commentary.
func (*Service) PdplAI ¶
PdplAI is POST /reports/pdpl/ai-summary (INV-5): the commentary is stored with the report and never changes it.
func (*Service) RunPending ¶
RunPending is the body of the send job: every definition the schedule marked is unmarked, then sent once (POST-2). The mark is cleared before the send, so a crash cannot send it twice; a failed send is in the history and is not retried by itself.
func (*Service) SaveDefinition ¶
func (s *Service) SaveDefinition(ctx context.Context, actor string, in DefinitionInput) (Definition, error)
SaveDefinition is PUT /reports/definition (admin): name, options and recipients, with the core_audit row in the same write.
func (*Service) SavePdplOrg ¶
SavePdplOrg is PUT /reports/pdpl/org: every field is checked (INV-8).
func (*Service) ScheduleOwner ¶
ScheduleOwner is what the report registers with core/schedule (key reports.def:<id>). It is off until an administrator turns it on (a clean install sends nothing), Monday 08:00 in the organisation's zone by default. When it comes due nothing is mailed inside the schedule's transaction: Start marks the definition (send_due_at) and the send job mails it, because sending talks to a mail server.
type SourceCount ¶
SourceCount counts the facts one source supplied.
type StatusCount ¶
StatusCount is how many open findings have one status.
type TopDetection ¶
type TopDetection struct {
Kind string `json:"kind"`
Title string `json:"title"`
Severity string `json:"severity"`
Device *DeviceRef `json:"device"`
// DeviceCount: how many devices the incident names when more than one (Device is the first by name), so the report says "12
// devices" instead of one device's name. Absent for one device, and in documents sent before it existed.
DeviceCount int `json:"device_count,omitempty"`
At string `json:"at"`
}
TopDetection is one incident that matters.