Documentation ¶
Index ¶
- Constants
- Variables
- func DbGetPackageLatestVersion(name string) (string, error)
- func DbPutFile(id string, version *Version) error
- func DbPutPackage(name string, packageInfo *PackageInfo, expireTime time.Time) error
- func DbPutVersion(name string, versionRaw string, version *Version, expireTime time.Time) error
- func DbPutVulnerability(vulnerability Vulnerability) error
- func HasMatchingVersion(versions []string, constraint *semver.Constraints) bool
- func Migrate(migrations []Migration)
- func PanicRecovery(handler http.Handler) http.Handler
- func ReadConfig(path string)
- func RenderNode(node Node) string
- func RenderText(node Node) string
- func SendError(subj string, body string)
- func Serve(publicFs fs.FS)
- func SetupDb()
- func UpdateVulnerabilities()
- func WriteHtml(node Node, writer http.ResponseWriter)
- func WriteHtmlWithStatus(node Node, status int, writer http.ResponseWriter)
- type AppConfig
- type Data
- type DbConfig
- type Dist
- type DistTags
- type Element
- type ElementAttr
- type FilePerformer
- type FileRow
- type Future
- type IntEntries
- type IntEntry
- type MailConfig
- type Migration
- type MigrationRow
- type Node
- type NpmUser
- type PackageInfo
- type PackageInfoPerformer
- type PackageRow
- type Page
- type PagesConfig
- type Result
- type SemverSpec
- type ServerConfig
- type Severity
- type SmartPerformer
- type SmartWorkPool
- type Stats
- type Tab
- type TextNode
- type UnsafeRawContent
- type Version
- type VersionInfo
- type VersionPerformer
- type VersionRow
- type Vulnerability
- type VulnerabilityResponse
- type VulnerabilityRow
- type VulnerabilityStats
Constants ¶
View Source
const ( Standalone elementType = iota Block Inline )
View Source
const MAX_UPLOAD_SIZE = 1000000
View Source
const SAFE_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
Variables ¶
View Source
var H1RE = regexp.MustCompile(`^\s*# (.*)\n`)
View Source
var TimeoutError = errors.New("timeout waiting for future")
Functions ¶
func DbPutPackage ¶
func DbPutPackage(name string, packageInfo *PackageInfo, expireTime time.Time) error
func DbPutVersion ¶
func DbPutVulnerability ¶
func DbPutVulnerability(vulnerability Vulnerability) error
func HasMatchingVersion ¶
func ReadConfig ¶
func ReadConfig(path string)
func RenderNode ¶
func RenderText ¶
func UpdateVulnerabilities ¶
func UpdateVulnerabilities()
func WriteHtml ¶
func WriteHtml(node Node, writer http.ResponseWriter)
func WriteHtmlWithStatus ¶
func WriteHtmlWithStatus(node Node, status int, writer http.ResponseWriter)
Types ¶
type AppConfig ¶
type AppConfig struct { Database DbConfig Mail MailConfig Pages PagesConfig Server ServerConfig }
var Config AppConfig
type Element ¶
type Element struct {
// contains filtered or unexported fields
}
func (*Element) WriteTextTo ¶
type ElementAttr ¶
type ElementAttr struct {
// contains filtered or unexported fields
}
func Attr ¶
func Attr(key, value string) ElementAttr
type FilePerformer ¶
type FilePerformer struct{}
func (FilePerformer) Get ¶
func (p FilePerformer) Get(id string) Data
func (FilePerformer) Perform ¶
func (p FilePerformer) Perform(id string) Result
func (FilePerformer) Put ¶
func (p FilePerformer) Put(id string, data Data)
type Future ¶
type Future struct {
// contains filtered or unexported fields
}
THREAD SAFE
func NewFutureResolved ¶
type IntEntries ¶
type IntEntries []IntEntry
func (IntEntries) Len ¶
func (l IntEntries) Len() int
func (IntEntries) Swap ¶
func (l IntEntries) Swap(i, j int)
type MailConfig ¶
type MigrationRow ¶
type Node ¶
type Node interface { WriteTo(b *strings.Builder, indent int) // mainly for multipart mail WriteTextTo(b *strings.Builder) }
func RenderTabs ¶
func VersionView ¶
type PackageInfo ¶
type PackageInfo struct { Name string `json:"name"` DistTags DistTags `json:"dist-tags"` Versions map[string]VersionInfo `json:"versions"` Time map[string]time.Time `json:"time"` }
func DbGetPackage ¶
func DbGetPackage(name string) (*PackageInfo, error)
func GetPackageInfo ¶
func GetPackageInfo(name string) (*PackageInfo, error)
func GetPackageInfoRegistry ¶
func GetPackageInfoRegistry(name string) (*PackageInfo, error)
func (*PackageInfo) GatherDependencies ¶
func (p *PackageInfo) GatherDependencies(versionRaw string) (*Version, error)
func (*PackageInfo) LatestTime ¶
func (p *PackageInfo) LatestTime() time.Time
func (*PackageInfo) LatestVersion ¶
func (p *PackageInfo) LatestVersion() VersionInfo
func (*PackageInfo) MaxVersion ¶
func (p *PackageInfo) MaxVersion(constraintRaw string) (VersionInfo, error)
type PackageInfoPerformer ¶
type PackageInfoPerformer struct{}
func (PackageInfoPerformer) Get ¶
func (p PackageInfoPerformer) Get(name string) Data
func (PackageInfoPerformer) Perform ¶
func (p PackageInfoPerformer) Perform(name string) Result
func (PackageInfoPerformer) Put ¶
func (p PackageInfoPerformer) Put(name string, data Data)
type PackageRow ¶
type PagesConfig ¶
type SemverSpec ¶
type SemverSpec struct {
Vulnerable []string `json:"vulnerable"`
}
type ServerConfig ¶
type ServerConfig struct {
Port int
}
type SmartPerformer ¶
type SmartWorkPool ¶
type SmartWorkPool struct {
// contains filtered or unexported fields
}
THREAD SAFE, because all the fields are thread safe
func NewSmartWorkPool ¶
func NewSmartWorkPool(performer SmartPerformer) *SmartWorkPool
func (*SmartWorkPool) ProcessKey ¶
func (s *SmartWorkPool) ProcessKey(key string) *Future
func (*SmartWorkPool) Start ¶
func (s *SmartWorkPool) Start(n int)
type Stats ¶
type Stats struct { Packages int `json:"packages"` Versions int `json:"versions"` Files int `json:"files"` DiskSpace int64 `json:"diskSpace"` VulnerabilityStats VulnerabilityStats `json:"vulnerabilityStats"` }
type UnsafeRawContent ¶
type UnsafeRawContent string
func (UnsafeRawContent) WriteTextTo ¶
func (t UnsafeRawContent) WriteTextTo(b *strings.Builder)
type Version ¶
type Version struct { Info VersionInfo `json:"info"` Time time.Time `json:"time"` Dependencies map[string][]string `json:"dependencies"` Publishers map[string]int `json:"publishers"` Vulnerabilities []Vulnerability `json:"vulnerabilities"` Stats Stats `json:"stats"` Errors []string `json:"error"` }
func NewVersion ¶
func NewVersion(versionInfo VersionInfo, time time.Time) *Version
func (*Version) GatherVulnerabilities ¶
type VersionInfo ¶
type VersionInfo struct { Name string `json:"name"` Version string `json:"version"` Description string `json:"description"` Homepage interface{} `json:"homepage"` License interface{} `json:"license"` Dependencies map[string]string `json:"dependencies"` DevDependencies map[string]string `json:"devDependencies"` NpmUser NpmUser `json:"_npmUser"` Dist Dist `json:"dist"` Os []string `json:"os"` Cpu []string `json:"cpu"` }
func (VersionInfo) GatherDependencies ¶
func (p VersionInfo) GatherDependencies(parent *Version, alsoDev bool)
func (VersionInfo) GetPublisher ¶
func (v VersionInfo) GetPublisher() string
func (VersionInfo) MatchPlatform ¶
func (p VersionInfo) MatchPlatform(os string, cpu string) bool
type VersionPerformer ¶
type VersionPerformer struct{}
func (VersionPerformer) Get ¶
func (p VersionPerformer) Get(key string) Data
func (VersionPerformer) Perform ¶
func (p VersionPerformer) Perform(key string) Result
func (VersionPerformer) Put ¶
func (p VersionPerformer) Put(key string, data Data)
type VersionRow ¶
type Vulnerability ¶
type Vulnerability struct { Id string `json:"id"` PackageManager string `json:"packageManager"` PackageName string `json:"packageName"` Title string `json:"title"` PublicationTime time.Time `json:"publicationTime"` Semver SemverSpec `json:"semver"` Severity Severity `json:"severity"` }
func DbGetVulnerabilitiesForPackages ¶
func DbGetVulnerabilitiesForPackages(packages []string) ([]Vulnerability, error)
func DbLastVulnerability ¶
func DbLastVulnerability() (*Vulnerability, error)
func GetVulnerabilities ¶
func GetVulnerabilities(page int) ([]Vulnerability, error)
type VulnerabilityResponse ¶
type VulnerabilityResponse struct { Status string `json:"status"` Vulnerabilities []Vulnerability `json:"vulnerabilities"` }
type VulnerabilityRow ¶
type VulnerabilityStats ¶
type VulnerabilityStats struct { LowCount int `json:"lowCount"` MediumCount int `json:"mediumCount"` HighCount int `json:"highCount"` CriticalCount int `json:"criticalCount"` }
func GetVulnerabilityStats ¶
func GetVulnerabilityStats(vulnerabilities []Vulnerability) VulnerabilityStats
Click to show internal directories.
Click to hide internal directories.