Skip to content

internal/model

import "github.com/nuqs-org/nuqs/internal/model"

Package model holds the small set of types that every part of Nuqs shares.

A scan finds hosts, each host has services (open ports), and checks turn services into findings. Nothing in here does any work, it only describes data.

Functions

FindingID

FindingID builds a stable ID for a finding. The same problem on the same host and port always gets the same ID, which lets us compare scans later.

func FindingID(host, checkID string, port int, protocol string) string

Defined in internal/model/model.go:125

Types

Confidence

Confidence says how sure we are that a finding is real.

type Confidence string

Defined in internal/model/model.go:64

The two confidence levels.

const (
    // Confirmed means we saw the problem ourselves, like a login that worked.
    Confirmed Confidence = "confirmed"
    // Inferred means we only know it from a version number, or Nmap only
    // guessed the service from the port. Either way it may not be real.
    Inferred Confidence = "inferred"
)

Defined in internal/model/model.go:67

Confidence.UnmarshalText

UnmarshalText reads a confidence back and refuses unknown values, so a broken saved report fails loudly.

func (c *Confidence) UnmarshalText(b []byte) error

Defined in internal/model/model.go:80

Confidence.Valid

Valid reports whether c is Confirmed or Inferred.

func (c Confidence) Valid() bool

Defined in internal/model/model.go:76

Finding

Finding is one problem that a check found on a service.

type Finding struct {
    ID         string     `json:"id"`
    CheckID    string     `json:"check_id"`
    Title      string     `json:"title"`
    Severity   Severity   `json:"severity"`
    Confidence Confidence `json:"confidence"`
    Host       string     `json:"host"`
    Port       int        `json:"port"`
    Protocol   string     `json:"protocol"`
    Evidence   string     `json:"evidence"` // what we actually saw, so people can trust it
    Fix        string     `json:"fix"`
}

Defined in internal/model/model.go:110

Host

Host is one machine that answered during the scan.

type Host struct {
    Address   string    `json:"address"`
    Hostnames []string  `json:"hostnames,omitempty"`
    Services  []Service `json:"services,omitempty"`
}

Defined in internal/model/model.go:103

Service

Service is one open port on a host, plus whatever Nmap could tell about it.

type Service struct {
    Port     int    `json:"port"`
    Protocol string `json:"protocol"`          // "tcp" or "udp"
    Name     string `json:"name,omitempty"`    // what Nmap thinks it is, like "http" or "ftp"
    Product  string `json:"product,omitempty"` // like "OpenSSH"
    Version  string `json:"version,omitempty"` // like "9.6p1"
    Tunnel   string `json:"tunnel,omitempty"`  // "ssl" when the service runs over TLS
    // Guessed is true when Nmap couldn't recognise the service and only
    // named it from the port number, like "telnet" for anything on port 23.
    Guessed bool `json:"guessed,omitempty"`
}

Defined in internal/model/model.go:90

Severity

Severity says how bad a finding is.

type Severity int

Defined in internal/model/model.go:13

Severity levels, lowest first.

const (
    Info Severity = iota
    Low
    Medium
    High
    Critical
)

Defined in internal/model/model.go:16

ParseSeverity

ParseSeverity turns a name like "High" or "high" back into a Severity.

func ParseSeverity(name string) (Severity, error)

Defined in internal/model/model.go:35

Severity.MarshalText

MarshalText writes the severity as its name, so JSON shows "high" and not 3.

func (s Severity) MarshalText() ([]byte, error)

Defined in internal/model/model.go:46

Severity.String

String returns the lowercase name, for example "high".

func (s Severity) String() string

Defined in internal/model/model.go:27

Severity.UnmarshalText

UnmarshalText reads a severity name back.

func (s *Severity) UnmarshalText(b []byte) error

Defined in internal/model/model.go:54