Versions in this module Expand all Collapse all v0 v0.1.0 Jul 11, 2026 Changes in this version + const CWEViewCWECrossSection + const CWEViewComprehensiveDictionary + const CWEViewDevelopmentConcepts + const CWEViewHardwareDesign + const CWEViewResearchConcepts + const DefaultBaseURL + const DefaultTimeout + const DefaultUserAgent + const Version + var CWETop25 = []int + var OWASPTop10 = map[string][]int + var SANSTop25 = []int + func CompareCWEIDs(a, b string) (int, error) + func CountByAbstraction(r *Registry, a Abstraction) int + func CountByLikelihood(r *Registry, l LikelihoodOfExploit) int + func CountByScope(r *Registry, scope ConsequenceScope) int + func CountByStatus(r *Registry, s Status) int + func ExtractCWEIDs(text string) []string + func ExtractFirstCWEID(text string) string + func FormatCWEID(id string) (string, error) + func FormatCWEIDFromInt(id int) string + func GetOWASPCategories(cweID int) []string + func GetOWASPCategory(cweID int) string + func GroupByAbstraction(cwes []*CWE) map[Abstraction][]*CWE + func GroupByLikelihood(cwes []*CWE) map[LikelihoodOfExploit][]*CWE + func GroupByStatus(cwes []*CWE) map[Status][]*CWE + func IsCWEID(text string) bool + func IsInOWASPTop10(cweID int) bool + func IsInSANSTop25(cweID int) bool + func IsInTop25(cweID int) bool + func IsInWellKnownView(viewID int) bool + func MarshalCSV(cwes []*CWE) ([]byte, error) + func MarshalJSON(cwe *CWE) ([]byte, error) + func MarshalJSONList(cwes []*CWE) ([]byte, error) + func MarshalXML(cwe *CWE) ([]byte, error) + func ParseCWEID(id string) (int, error) + func ValidateCWEID(text string) error + type APIClient struct + func NewAPIClient(opts ...APIClientOption) *APIClient + func (c *APIClient) Close() + func (c *APIClient) GetAncestors(ctx context.Context, id int) ([]Relationship, error) + func (c *APIClient) GetBaseURL() string + func (c *APIClient) GetCWEs(ctx context.Context, ids []int) (map[string]*CWE, error) + func (c *APIClient) GetCategory(ctx context.Context, id int) (*Category, error) + func (c *APIClient) GetChildren(ctx context.Context, id int, viewID ...int) ([]Relationship, error) + func (c *APIClient) GetDescendants(ctx context.Context, id int) ([]Relationship, error) + func (c *APIClient) GetHTTPClient() *HTTPClient + func (c *APIClient) GetParents(ctx context.Context, id int, viewID ...int) ([]Relationship, error) + func (c *APIClient) GetRateLimiter() *RateLimiter + func (c *APIClient) GetVersion(ctx context.Context) (*VersionResponse, error) + func (c *APIClient) GetView(ctx context.Context, id int) (*View, error) + func (c *APIClient) GetWeakness(ctx context.Context, id int) (*CWE, error) + func (c *APIClient) SetBaseURL(url string) + func (c *APIClient) SetHTTPClient(client *HTTPClient) + func (c *APIClient) SetRateLimiter(limiter *RateLimiter) + type APIClientOption func(*APIClient) + func WithAPIBaseURL(url string) APIClientOption + func WithAPIHTTPClient(opts ...HTTPClientOption) APIClientOption + func WithAPIRateLimit(rate float64, burst int) APIClientOption + func WithAPIRetry(maxRetries int, delay time.Duration) APIClientOption + func WithAPITimeout(timeout time.Duration) APIClientOption + type APIError struct + Method string + StatusCode int + URL string + func NewAPIError(statusCode int, url, method string) *APIError + type APIResponse struct + Data json.RawMessage + Message string + type Abstraction string + const AbstractionBase + const AbstractionClass + const AbstractionPillar + const AbstractionVariant + func AllAbstractionValues() []Abstraction + func ParseAbstraction(s string) (Abstraction, error) + func (a Abstraction) AbstractionOrder() int + func (a Abstraction) IsValid() bool + func (a Abstraction) String() string + type AlternateTerm struct + Description string + Term string + type ApplicablePlatforms struct + Architectures []PlatformEntry + Languages []PlatformEntry + OperatingSystems []PlatformEntry + Technologies []PlatformEntry + type BasicFetcher struct + func NewBasicFetcher(client *APIClient) *BasicFetcher + func (f *BasicFetcher) Fetch(ctx context.Context, id int) (*CWE, error) + func (f *BasicFetcher) FetchCategory(ctx context.Context, id int) (*Category, error) + func (f *BasicFetcher) FetchView(ctx context.Context, id int) (*View, error) + func (f *BasicFetcher) FetchWithRelations(ctx context.Context, id int, viewID ...int) (*CWE, error) + type CWE struct + Abstraction Abstraction + AlternateTerms []AlternateTerm + ApplicablePlatforms *ApplicablePlatforms + CWEType string + CommonConsequences []Consequence + ContentHistory *ContentHistory + DemonstrativeExamples []DemonstrativeExample + Description string + ExtendedDescription string + ID int + LikelihoodOfExploit LikelihoodOfExploit + ModesOfIntroduction []Introduction + Name string + Notes string + ObservedExamples []ObservedExample + PotentialMitigations []Mitigation + References []Reference + Relationships []Relationship + Status Status + Structure Structure + URL string + func Deduplicate(cwes []*CWE) []*CWE + func Filter(cwes []*CWE, opts ...FilterOption) []*CWE + func FindBaseWeaknesses(r *Registry) []*CWE + func FindByAbstraction(r *Registry, abstraction Abstraction) []*CWE + func FindByConsequenceScope(r *Registry, scope ConsequenceScope) []*CWE + func FindByID(r *Registry, id int) (*CWE, bool) + func FindByKeyword(r *Registry, keyword string) []*CWE + func FindByLikelihood(r *Registry, likelihood LikelihoodOfExploit) []*CWE + func FindByStatus(r *Registry, status Status) []*CWE + func FindByStructure(r *Registry, structure Structure) []*CWE + func FindChains(r *Registry) []*CWE + func FindComposites(r *Registry) []*CWE + func FindTopLevel(r *Registry) []*CWE + func NewCWE(id int, name string) *CWE + func SortByAbstraction(cwes []*CWE) []*CWE + func SortByID(cwes []*CWE) []*CWE + func SortByName(cwes []*CWE) []*CWE + func UnmarshalCSV(data []byte) ([]*CWE, error) + func UnmarshalJSON(data []byte) (*CWE, error) + func UnmarshalJSONList(data []byte) ([]*CWE, error) + func UnmarshalXML(data []byte) (*CWE, error) + func (c *CWE) CWEID() string + func (c *CWE) GetChainIDs() []int + func (c *CWE) GetChildIDs() []int + func (c *CWE) GetParentIDs() []int + func (c *CWE) GetPeerIDs() []int + func (c *CWE) HasConsequenceScope(scope ConsequenceScope) bool + func (c *CWE) IsBase() bool + func (c *CWE) IsCategory() bool + func (c *CWE) IsChain() bool + func (c *CWE) IsComposite() bool + func (c *CWE) IsCompoundElement() bool + func (c *CWE) IsDeprecated() bool + func (c *CWE) IsPillar() bool + func (c *CWE) IsStable() bool + func (c *CWE) IsVariant() bool + func (c *CWE) IsView() bool + func (c *CWE) IsWeakness() bool + func (c *CWE) Validate() error + type CWEError struct + Code string + Detail string + Err error + Message string + func (e *CWEError) Error() string + func (e *CWEError) Unwrap() error + type CWENotFoundError struct + ID int + func NewCWENotFoundError(id int) *CWENotFoundError + type CWEsResponse struct + Data json.RawMessage + Weaknesses map[string]*CWE + type CategoriesResponse struct + Categories []Category + Data json.RawMessage + type Category struct + ContentHistory *ContentHistory + Description string + ID int + Name string + Notes string + References []Reference + Relationships []Relationship + Status Status + func NewCategory(id int, name string) *Category + type CompoundElement struct + Description string + ID int + Name string + Relationships []Relationship + Status Status + Structure Structure + func NewCompoundElement(id int, name string, structure Structure) *CompoundElement + type Consequence struct + Impacts []ConsequenceImpact + Likelihood LikelihoodOfExploit + Note string + Scopes []ConsequenceScope + func (c *Consequence) HasImpact(impact ConsequenceImpact) bool + func (c *Consequence) HasScope(scope ConsequenceScope) bool + func (c *Consequence) MaxImpact() ConsequenceImpact + func (c *Consequence) Validate() error + type ConsequenceImpact string + const ImpactHigh + const ImpactLow + const ImpactMedium + const ImpactUnknown + func AllConsequenceImpactValues() []ConsequenceImpact + func ParseConsequenceImpact(s string) (ConsequenceImpact, error) + func (i ConsequenceImpact) ImpactOrder() int + func (i ConsequenceImpact) IsValid() bool + func (i ConsequenceImpact) String() string + type ConsequenceScope string + const ScopeAccessControl + const ScopeAccountability + const ScopeAuthentication + const ScopeAuthorization + const ScopeAvailability + const ScopeConfidentiality + const ScopeIntegrity + const ScopeNonRepudiation + func AllConsequenceScopeValues() []ConsequenceScope + func ParseConsequenceScope(s string) (ConsequenceScope, error) + func (s ConsequenceScope) IsValid() bool + func (s ConsequenceScope) String() string + type ConsequenceScopeCount struct + Count int + Scope ConsequenceScope + type ContentHistory struct + Modifications []HistoryEntry + Submission *HistoryEntry + type DataFetcher interface + Fetch func(ctx context.Context, id int) (*CWE, error) + type DemonstrativeExample struct + BodyText string + IntroText string + type Effectiveness string + const EffectivenessDefenseInDepth + const EffectivenessHigh + const EffectivenessLimited + const EffectivenessModerate + const EffectivenessSOARPartial + const EffectivenessUnknown + func AllEffectivenessValues() []Effectiveness + func ParseEffectiveness(s string) (Effectiveness, error) + func (e Effectiveness) IsValid() bool + func (e Effectiveness) String() string + type FilterOption struct + Abstraction Abstraction + Keyword string + Likelihood LikelihoodOfExploit + MaxID int + MinID int + Scope ConsequenceScope + Status Status + Structure Structure + type HTTPClient struct + func NewHTTPClient(baseURL string, opts ...HTTPClientOption) *HTTPClient + func (c *HTTPClient) Close() + func (c *HTTPClient) Get(ctx context.Context, path string, result interface{}) error + func (c *HTTPClient) GetBaseURL() string + func (c *HTTPClient) GetHTTPClient() *http.Client + func (c *HTTPClient) GetMaxRetries() int + func (c *HTTPClient) GetRateLimiter() *RateLimiter + func (c *HTTPClient) GetRaw(ctx context.Context, path string) ([]byte, error) + func (c *HTTPClient) GetRetryDelay() time.Duration + func (c *HTTPClient) Post(ctx context.Context, path string, body interface{}, result interface{}) error + func (c *HTTPClient) PostForm(ctx context.Context, path string, data url.Values, result interface{}) error + func (c *HTTPClient) SetBaseURL(url string) + func (c *HTTPClient) SetHTTPClient(client *http.Client) + func (c *HTTPClient) SetMaxRetries(maxRetries int) + func (c *HTTPClient) SetRateLimiter(limiter *RateLimiter) + func (c *HTTPClient) SetRetryDelay(delay time.Duration) + type HTTPClientOption func(*HTTPClient) + func WithHTTPClient(client *http.Client) HTTPClientOption + func WithHTTPRateLimiter(rate float64, burst int) HTTPClientOption + func WithHTTPTimeout(timeout time.Duration) HTTPClientOption + func WithRetry(maxRetries int, delay time.Duration) HTTPClientOption + func WithUserAgent(ua string) HTTPClientOption + type HistoryEntry struct + Comment string + Date string + Name string + Organization string + type Introduction struct + Description string + Phase IntroductionPhase + type IntroductionPhase string + const PhaseArchitectureAndDesign + const PhaseBuildAndCompilation + const PhaseImplementation + const PhaseInstallation + const PhaseOperation + const PhasePolicy + const PhaseSystemConfiguration + func AllIntroductionPhaseValues() []IntroductionPhase + func ParseIntroductionPhase(s string) (IntroductionPhase, error) + func (p IntroductionPhase) IsValid() bool + func (p IntroductionPhase) String() string + type InvalidCWEIDError struct + ID string + func NewInvalidCWEIDError(id string) *InvalidCWEIDError + type LikelihoodOfExploit string + const LikelihoodHigh + const LikelihoodLow + const LikelihoodMedium + const LikelihoodUnknown + func AllLikelihoodOfExploitValues() []LikelihoodOfExploit + func ParseLikelihoodOfExploit(s string) (LikelihoodOfExploit, error) + func (l LikelihoodOfExploit) IsValid() bool + func (l LikelihoodOfExploit) LikelihoodOrder() int + func (l LikelihoodOfExploit) String() string + type Mitigation struct + Description string + Effectiveness Effectiveness + Phase MitigationPhase + Strategy string + type MitigationPhase string + const MitigationPhaseArchitectureAndDesign + const MitigationPhaseBuildAndCompilation + const MitigationPhaseImplementation + const MitigationPhaseInstallation + const MitigationPhaseOperation + const MitigationPhasePolicy + const MitigationPhaseSystemConfiguration + func AllMitigationPhaseValues() []MitigationPhase + func ParseMitigationPhase(s string) (MitigationPhase, error) + func (m MitigationPhase) IsValid() bool + func (m MitigationPhase) String() string + type MultipleFetcher struct + func NewMultipleFetcher(client *APIClient) *MultipleFetcher + func (f *MultipleFetcher) FetchMultiple(ctx context.Context, ids []int) (map[string]*CWE, error) + func (f *MultipleFetcher) FetchMultipleToRegistry(ctx context.Context, ids []int, registry *Registry) error + type Navigator struct + func NewNavigator(r *Registry) *Navigator + func (n *Navigator) Ancestors(id int) []*CWE + func (n *Navigator) CanAlsoBe(id int) []*CWE + func (n *Navigator) CanFollow(id int) []*CWE + func (n *Navigator) CanPrecede(id int) []*CWE + func (n *Navigator) ChainMembers(id int) []*CWE + func (n *Navigator) Children(id int) []*CWE + func (n *Navigator) CompositeMembers(id int) []*CWE + func (n *Navigator) Descendants(id int) []*CWE + func (n *Navigator) IsAncestorOf(ancestor, descendant int) bool + func (n *Navigator) IsDescendantOf(descendant, ancestor int) bool + func (n *Navigator) IsRelated(a, b int) bool + func (n *Navigator) Parents(id int) []*CWE + func (n *Navigator) Peers(id int) []*CWE + func (n *Navigator) RelationshipDepth(ancestor, descendant int) int + func (n *Navigator) RequiredBy(id int) []*CWE + func (n *Navigator) Requires(id int) []*CWE + func (n *Navigator) ShortestPath(from, to int) []int + func (n *Navigator) Siblings(id int) []*CWE + func (n *Navigator) String() string + type ObservedExample struct + Description string + Link string + Reference string + type ParseError struct + Offset int64 + func NewParseError(detail string, offset int64) *ParseError + type PlatformEntry struct + Name string + Prevalence Prevalence + type PlatformType string + const PlatformArchitecture + const PlatformLanguage + const PlatformOperatingSystem + const PlatformTechnology + func AllPlatformTypeValues() []PlatformType + func ParsePlatformType(s string) (PlatformType, error) + func (p PlatformType) IsValid() bool + func (p PlatformType) String() string + type Prevalence string + const PrevalenceOften + const PrevalenceRarely + const PrevalenceSometimes + const PrevalenceUndetermined + func AllPrevalenceValues() []Prevalence + func ParsePrevalence(s string) (Prevalence, error) + func (p Prevalence) IsValid() bool + func (p Prevalence) String() string + type RateLimitError struct + RetryAfter time.Duration + func NewRateLimitError(retryAfter time.Duration) *RateLimitError + type RateLimiter struct + func NewRateLimiter(rate float64, burst int) *RateLimiter + func (r *RateLimiter) Allow() bool + func (r *RateLimiter) GetBurst() int + func (r *RateLimiter) GetInterval() time.Duration + func (r *RateLimiter) GetRate() float64 + func (r *RateLimiter) ResetLastRequest() + func (r *RateLimiter) SetInterval(interval time.Duration) + func (r *RateLimiter) Tokens() float64 + func (r *RateLimiter) Wait(ctx context.Context) error + func (r *RateLimiter) WaitForRequest() + type Reference struct + Author string + ID int + Title string + URL string + type Registry struct + func NewRegistry() *Registry + func (r *Registry) BuildIndexes() + func (r *Registry) CategoryCount() int + func (r *Registry) Clear() + func (r *Registry) CompoundElementCount() int + func (r *Registry) Contains(id int) bool + func (r *Registry) ExportCSV() ([]byte, error) + func (r *Registry) ExportJSON() ([]byte, error) + func (r *Registry) Get(id int) (*CWE, bool) + func (r *Registry) GetAll() []*CWE + func (r *Registry) GetAllCategories() []*Category + func (r *Registry) GetAllViews() []*View + func (r *Registry) GetAncestorIDs(id int) []int + func (r *Registry) GetCategory(id int) (*Category, bool) + func (r *Registry) GetCategoryMembers(categoryID int) []int + func (r *Registry) GetChildIDs(id int) []int + func (r *Registry) GetCompoundElement(id int) (*CompoundElement, bool) + func (r *Registry) GetDescendantIDs(id int) []int + func (r *Registry) GetMemberOfIDs(id int) []int + func (r *Registry) GetParentIDs(id int) []int + func (r *Registry) GetPeerIDs(id int) []int + func (r *Registry) GetView(id int) (*View, bool) + func (r *Registry) GetViewMembers(viewID int) []int + func (r *Registry) ImportJSON(jsonData []byte) error + func (r *Registry) IndexesBuilt() bool + func (r *Registry) Register(cwe *CWE) error + func (r *Registry) RegisterCategory(cat *Category) error + func (r *Registry) RegisterCompoundElement(ce *CompoundElement) error + func (r *Registry) RegisterView(view *View) error + func (r *Registry) Remove(id int) error + func (r *Registry) RemoveCategory(id int) error + func (r *Registry) RemoveView(id int) error + func (r *Registry) Size() int + func (r *Registry) ViewCount() int + type RelationsResponse struct + Data json.RawMessage + type Relationship struct + CWEID int + ChainID int + Nature RelationshipNature + Ordinal string + ViewID int + func NewRelationship(nature RelationshipNature, cweID int) *Relationship + func NewRelationshipWithView(nature RelationshipNature, cweID, viewID int) *Relationship + func (r *Relationship) IsDependency() bool + func (r *Relationship) IsHierarchical() bool + func (r *Relationship) IsPeer() bool + func (r *Relationship) IsPrimary() bool + func (r *Relationship) IsSequential() bool + func (r *Relationship) Validate() error + type RelationshipError struct + From string + Nature RelationshipNature + To string + func NewRelationshipError(from, to string, nature RelationshipNature) *RelationshipError + type RelationshipNature string + const RelationshipCanAlsoBe + const RelationshipCanFollow + const RelationshipCanPrecede + const RelationshipChildOf + const RelationshipHasMember + const RelationshipMemberOf + const RelationshipParentOf + const RelationshipPeerOf + const RelationshipRequiredBy + const RelationshipRequires + func AllRelationshipNatureValues() []RelationshipNature + func ParseRelationshipNature(s string) (RelationshipNature, error) + func (r RelationshipNature) IsDependency() bool + func (r RelationshipNature) IsHierarchical() bool + func (r RelationshipNature) IsPeer() bool + func (r RelationshipNature) IsSequential() bool + func (r RelationshipNature) IsValid() bool + func (r RelationshipNature) String() string + type Statistics struct + ByAbstraction map[Abstraction]int + ByLikelihood map[LikelihoodOfExploit]int + ByStatus map[Status]int + ByStructure map[Structure]int + CategoryCount int + CompoundElementCount int + TopScopes []ConsequenceScopeCount + TotalCount int + ViewCount int + WeaknessCount int + func ComputeStatistics(r *Registry) *Statistics + type Status string + const StatusDeprecated + const StatusDraft + const StatusIncomplete + const StatusObsolete + const StatusStable + const StatusUsable + func AllStatusValues() []Status + func ParseStatus(s string) (Status, error) + func (s Status) IsValid() bool + func (s Status) String() string + type Structure string + const StructureChain + const StructureComposite + const StructureSimple + func AllStructureValues() []Structure + func ParseStructure(s string) (Structure, error) + func (s Structure) IsValid() bool + func (s Structure) String() string + type TreeFetcher struct + func NewTreeFetcher(client *APIClient, registry *Registry, maxDepth int) *TreeFetcher + func (f *TreeFetcher) FetchFullTree(ctx context.Context, rootID int) error + func (f *TreeFetcher) FetchWithAncestors(ctx context.Context, id int) error + func (f *TreeFetcher) FetchWithDescendants(ctx context.Context, id int) error + func (f *TreeFetcher) GetRegistry() *Registry + type TreeNode struct + CWE *CWE + Children []*TreeNode + Depth int + Parent *TreeNode + func BuildForest(r *Registry) []*TreeNode + func BuildTree(r *Registry, rootID int) *TreeNode + func BuildViewTree(r *Registry, viewID int) *TreeNode + func NewTreeNode(cwe *CWE) *TreeNode + func (n *TreeNode) AddChild(child *TreeNode) + func (n *TreeNode) Count() int + func (n *TreeNode) Find(id int) *TreeNode + func (n *TreeNode) IsLeaf() bool + func (n *TreeNode) IsRoot() bool + func (n *TreeNode) LeafNodes() []*TreeNode + func (n *TreeNode) MaxDepth() int + func (n *TreeNode) Path() []*TreeNode + func (n *TreeNode) String() string + func (n *TreeNode) Walk(fn func(*TreeNode) bool) + func (n *TreeNode) WalkBFS(fn func(*TreeNode) bool) + type ValidationError struct + Field string + Value string + func NewValidationError(field, value string) *ValidationError + type VersionResponse struct + Name string + ReleaseDate string + Version string + type View struct + ContentHistory *ContentHistory + Description string + ID int + Members []ViewMember + Name string + References []Reference + Status Status + Type ViewType + func NewView(id int, name string, viewType ViewType) *View + type ViewMember struct + CWEID int + Direct bool + Predicate string + ViewID int + type ViewType string + const ViewTypeExplicitSlice + const ViewTypeGraph + const ViewTypeImplicitSlice + func AllViewTypeValues() []ViewType + func ParseViewType(s string) (ViewType, error) + func (v ViewType) IsValid() bool + func (v ViewType) String() string + type ViewsResponse struct + Data json.RawMessage + Views []View + type WeaknessesResponse struct + Data json.RawMessage + Weaknesses []CWE + type XMLParser struct + func NewXMLParser() *XMLParser + func (p *XMLParser) Parse(reader io.Reader) (*Registry, error) + func (p *XMLParser) ParseBytes(data []byte) (*Registry, error) + func (p *XMLParser) ParseFile(path string) (*Registry, error)