mirror of
https://github.com/BaaRai/ARTEX.git
synced 2026-11-24 09:00:54 +08:00
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
99cda59643 | ||
|
|
9cd000dbd0 |
+1
-1
@@ -4,7 +4,7 @@ web/.next
|
||||
web/out
|
||||
server/webui/dist
|
||||
/artex
|
||||
data
|
||||
/data
|
||||
keys
|
||||
backups
|
||||
.env
|
||||
|
||||
@@ -6,6 +6,7 @@ All notable changes to this project are documented in this file. The format is b
|
||||
|
||||
### Added
|
||||
|
||||
- **Pentest knowledge pack**: the planner and the workers can call a read-only `knowledge_lookup` tool to resolve a MITRE ATT&CK technique, an OWASP WSTG test or a CWE weakness by id or keyword, and cite the id in findings and facts. The pack is generated from the official sources by `scripts/knowledge/build.py`, with the source URL, license, retrieval date and source SHA-256 recorded, keeps its own licenses in `knowledge/NOTICE` and `knowledge/licenses`, and is embedded in the binary, so no network is needed at runtime. Descriptions are capped and each entry carries the canonical URL (#521).
|
||||
- **Wildcard domains in asset scope**: a scope line such as `*.example.com`, the way bug bounty programs write a domain and its subdomains, is accepted in company and task asset scope and stored as the `example.com` domain rule, which already covers its subdomains. A URL form (`https://*.example.com/`) works too. The wildcard is accepted only on a registrable domain: `*.api.example.com`, `*.co.uk` and `*.<IP>` are still rejected, because no rule covers only a subdomain's subdomains (#519).
|
||||
- **Stream viewer direction filter** (follow-up to #380): the Traffic detail's Stream tab can show all messages, client-to-server messages or server-to-client messages. Pagination and refresh keep the selected direction, changing the filter resets the list, and opening another exchange resets the direction to all. Recording-limit warnings remain visible but are excluded from the displayed message counts.
|
||||
- **Security response headers on every response**: `X-Content-Type-Options: nosniff`, a same-origin referrer policy, `X-Frame-Options: SAMEORIGIN` and a `frame-ancestors 'self'` CSP are now set by one wrapper around the whole handler tree, so the JSON API carries them too; previously only the console route did. Console documents additionally get `Permissions-Policy` and COOP/CORP. `Strict-Transport-Security` is sent only when the request is known to be HTTPS: directly over TLS, or via `X-Forwarded-Proto: https` from a peer in `ARTEX_TRUSTED_PROXIES`, so a direct client cannot claim HTTPS on its own. The README reverse-proxy recipe now starts with an 80 to 443 redirect.
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
package agent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"strings"
|
||||
|
||||
"github.com/Autumn-27/artex/knowledge"
|
||||
actool "github.com/Autumn-27/norma/tool"
|
||||
)
|
||||
|
||||
// knowledgeLookup is a read-only taxonomy lookup shared by the planner and the
|
||||
// workers. It has no task store dependency: the pack is embedded in the binary.
|
||||
func (t *ToolSet) knowledgeLookup() actool.CoreTool {
|
||||
return readTool("knowledge_lookup",
|
||||
"Look up a stable security taxonomy entry by id or keyword. Sources: attack (MITRE ATT&CK technique), wstg (OWASP Web Security Testing Guide test), cwe (MITRE Common Weakness Enumeration). Use it to choose a test or technique while planning, or to cite an id when reporting a finding or fact. Returns id, name, category, a capped description and the canonical url; truncated=true means the full text is at the url. Read-only.",
|
||||
obj(map[string]any{
|
||||
"source": str("taxonomy to search: attack, wstg or cwe"),
|
||||
"query": str("entry id (for example T1190, WSTG-ATHN-01, CWE-79) or keywords"),
|
||||
"limit": intp("maximum matches, default 5, max 20"),
|
||||
}, "source", "query"),
|
||||
knowledgeLookupRun)
|
||||
}
|
||||
|
||||
func knowledgeLookupRun(_ context.Context, in json.RawMessage) (actool.Result, error) {
|
||||
var a struct {
|
||||
Source string `json:"source"`
|
||||
Query string `json:"query"`
|
||||
Limit int `json:"limit"`
|
||||
}
|
||||
if err := json.Unmarshal(in, &a); err != nil {
|
||||
return actool.Errorf("invalid input: " + err.Error()), nil
|
||||
}
|
||||
pack, err := knowledge.Default()
|
||||
if err != nil {
|
||||
return actool.Errorf(err.Error()), nil
|
||||
}
|
||||
source := strings.ToLower(strings.TrimSpace(a.Source))
|
||||
matches, total, err := pack.Search(source, a.Query, a.Limit)
|
||||
if err != nil {
|
||||
return actool.Errorf(err.Error()), nil
|
||||
}
|
||||
return jsonResult(map[string]any{
|
||||
"source": source,
|
||||
"query": strings.TrimSpace(a.Query),
|
||||
"matches": matches,
|
||||
"total": total,
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package agent
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestKnowledgeLookupRunExactID(t *testing.T) {
|
||||
res, err := knowledgeLookupRun(t.Context(), json.RawMessage(`{"source":"attack","query":"T1190"}`))
|
||||
if err != nil {
|
||||
t.Fatalf("run: %v", err)
|
||||
}
|
||||
if res.IsError {
|
||||
t.Fatalf("unexpected tool error: %s", res.Flatten())
|
||||
}
|
||||
out := res.Flatten()
|
||||
for _, want := range []string{`"T1190"`, "Exploit Public-Facing Application", "attack.mitre.org"} {
|
||||
if !strings.Contains(out, want) {
|
||||
t.Errorf("output missing %q: %s", want, out)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestKnowledgeLookupRunKeyword(t *testing.T) {
|
||||
res, err := knowledgeLookupRun(t.Context(), json.RawMessage(`{"source":"wstg","query":"default credentials","limit":3}`))
|
||||
if err != nil {
|
||||
t.Fatalf("run: %v", err)
|
||||
}
|
||||
if res.IsError {
|
||||
t.Fatalf("unexpected tool error: %s", res.Flatten())
|
||||
}
|
||||
if !strings.Contains(res.Flatten(), "WSTG-ATHN-01") {
|
||||
t.Errorf("output does not contain WSTG-ATHN-01: %s", res.Flatten())
|
||||
}
|
||||
}
|
||||
|
||||
func TestKnowledgeLookupRunLimitIsClamped(t *testing.T) {
|
||||
res, err := knowledgeLookupRun(t.Context(), json.RawMessage(`{"source":"cwe","query":"data","limit":100}`))
|
||||
if err != nil {
|
||||
t.Fatalf("run: %v", err)
|
||||
}
|
||||
if res.IsError {
|
||||
t.Fatalf("unexpected tool error: %s", res.Flatten())
|
||||
}
|
||||
var out struct {
|
||||
Matches []map[string]any `json:"matches"`
|
||||
Total int `json:"total"`
|
||||
}
|
||||
if err := json.Unmarshal([]byte(res.Flatten()), &out); err != nil {
|
||||
t.Fatalf("decode: %v", err)
|
||||
}
|
||||
if len(out.Matches) > 20 {
|
||||
t.Fatalf("matches = %d, want at most 20", len(out.Matches))
|
||||
}
|
||||
if out.Total <= len(out.Matches) {
|
||||
t.Fatalf("total = %d, matches = %d", out.Total, len(out.Matches))
|
||||
}
|
||||
}
|
||||
|
||||
func TestKnowledgeLookupRunErrors(t *testing.T) {
|
||||
cases := []struct {
|
||||
name, in, want string
|
||||
}{
|
||||
{"unknown source", `{"source":"nope","query":"x"}`, "unknown knowledge source"},
|
||||
{"empty query", `{"source":"attack","query":" "}`, "query is required"},
|
||||
{"invalid json", `{`, "invalid input"},
|
||||
}
|
||||
for _, c := range cases {
|
||||
t.Run(c.name, func(t *testing.T) {
|
||||
res, err := knowledgeLookupRun(t.Context(), json.RawMessage(c.in))
|
||||
if err != nil {
|
||||
t.Fatalf("run: %v", err)
|
||||
}
|
||||
if !res.IsError || !strings.Contains(res.Flatten(), c.want) {
|
||||
t.Fatalf("result = %q (isError=%v), want error containing %q", res.Flatten(), res.IsError, c.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestKnowledgeLookupToolIsReadOnly(t *testing.T) {
|
||||
tool := (&ToolSet{}).knowledgeLookup()
|
||||
if tool.Name() != "knowledge_lookup" {
|
||||
t.Fatalf("name = %q", tool.Name())
|
||||
}
|
||||
if !tool.IsReadOnly(nil) {
|
||||
t.Fatal("tool is not read-only")
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -2567,7 +2567,7 @@ func (t *ToolSet) listWorkerTraces() actool.CoreTool {
|
||||
// PlannerTools is the read + intent-generation + goal-judgement tool set.
|
||||
func (t *ToolSet) PlannerTools() []actool.CoreTool {
|
||||
return []actool.CoreTool{
|
||||
t.graphOverview(), t.listFindings(), t.listFacts(), t.nodeDetail(),
|
||||
t.graphOverview(), t.listFindings(), t.listFacts(), t.nodeDetail(), t.knowledgeLookup(),
|
||||
// cold-digest §6.1: restore folded cold nodes (digest body → members → detail).
|
||||
t.expandDigest(),
|
||||
t.getWorkerOutput(), t.getWorkerTrace(), t.searchAllWorkerTraces(), t.listGoals(), t.addIntent(), t.proveGoal(), t.goalMet(),
|
||||
|
||||
@@ -711,6 +711,9 @@ func (t *ToolSet) WorkerTools() []actool.CoreTool {
|
||||
// node_detail: once a worker has an intent_id/node id, it can look up that node's
|
||||
// full detail (pairs with the review above).
|
||||
t.nodeDetail(),
|
||||
// knowledge_lookup: cite a stable ATT&CK/WSTG/CWE id when reporting a
|
||||
// finding or a fact, or look up a test while executing an intent.
|
||||
t.knowledgeLookup(),
|
||||
// The following tools are still [not given] to workers, reserved for
|
||||
// planner/main (reading context, cross-work retrospection are planning duties; a
|
||||
// worker only executes and writes back its single intent):
|
||||
|
||||
@@ -29,6 +29,8 @@ var noTargetTools = toolSet(
|
||||
"insert_assets", "add_company_scope", "add_task_scope", "list_assets",
|
||||
"list_untested_assets", "list_companies", "report_finding", "record_fact",
|
||||
"save_task_credential", "list_task_credentials", "ingest_bbot", "ingest_scan_output", "record_coverage",
|
||||
// taxonomy lookup: the input is an id or a keyword, never a connection
|
||||
"knowledge_lookup",
|
||||
// cross-task orchestration, findings and retests (server)
|
||||
"list_tasks", "list_llm_profiles", "spawn_task", "pause_task", "get_task_graph",
|
||||
"list_task_findings", "add_task_hint", "get_task_worker_trace",
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
Knowledge pack attribution
|
||||
|
||||
The files under knowledge/data/ are generated from the sources below and are
|
||||
distributed under their own terms. They are not covered by the repository's
|
||||
AGPL-3.0 license.
|
||||
|
||||
MITRE ATT&CK
|
||||
Copyright © 2026 The MITRE Corporation. This work is reproduced and
|
||||
distributed with the permission of The MITRE Corporation.
|
||||
License: knowledge/licenses/ATTACK-LICENSE.txt
|
||||
Source: https://github.com/mitre-attack/attack-stix-data
|
||||
|
||||
OWASP Web Security Testing Guide
|
||||
Copyright © OWASP Foundation. Licensed under CC-BY-SA-4.0.
|
||||
Changes: descriptions are shortened for tool output; ids, names and
|
||||
references are unchanged.
|
||||
License: knowledge/licenses/WSTG-LICENSE.txt
|
||||
Source: https://github.com/OWASP/wstg
|
||||
|
||||
MITRE CWE
|
||||
Copyright © 2006-2026 The MITRE Corporation. This work is reproduced and
|
||||
distributed with the permission of The MITRE Corporation.
|
||||
Terms: knowledge/licenses/CWE-TERMS.txt
|
||||
Source: https://cwe.mitre.org/data/csv/1000.csv
|
||||
|
||||
The canonical text and the full license terms are at the URL in each entry and
|
||||
in knowledge/licenses/.
|
||||
@@ -0,0 +1,63 @@
|
||||
# Knowledge pack
|
||||
|
||||
Small, versioned security taxonomy pack embedded in the ARTEX binary. It gives
|
||||
the planner and the workers stable identifiers to plan against and to cite in
|
||||
findings and facts:
|
||||
|
||||
- **attack**: MITRE ATT&CK Enterprise techniques (706 entries).
|
||||
- **wstg**: OWASP Web Security Testing Guide tests (133 entries).
|
||||
- **cwe**: MITRE Common Weakness Enumeration weaknesses (956 entries).
|
||||
|
||||
Each entry carries an id, a name, a category (tactics, WSTG category or CWE
|
||||
abstraction), a short description capped by the build script, a `truncated` flag
|
||||
when the description was cut, and the canonical URL.
|
||||
|
||||
## Sources and licenses
|
||||
|
||||
The data files are generated from the official sources and keep their own
|
||||
licenses. They are not covered by the repository's AGPL-3.0 license.
|
||||
|
||||
| source | license | source |
|
||||
|---|---|---|
|
||||
| attack | MITRE ATT&CK Terms of Use | https://github.com/mitre-attack/attack-stix-data |
|
||||
| wstg | CC-BY-SA-4.0 | https://github.com/OWASP/wstg |
|
||||
| cwe | MITRE CWE Terms of Use | https://cwe.mitre.org/data/csv/1000.csv |
|
||||
|
||||
See [NOTICE](NOTICE) and [licenses/](licenses/) for the attribution and the
|
||||
license texts. The WSTG descriptions are shortened; IDs, names and references
|
||||
are unchanged.
|
||||
|
||||
## Files
|
||||
|
||||
- `data/attack.json`, `data/wstg.json`, `data/cwe.json`: the embedded entries.
|
||||
- `data/sources.json`: source URL, license, retrieval date, source SHA-256 and
|
||||
entry count for each file.
|
||||
- `licenses/`: the license texts.
|
||||
- `../scripts/knowledge/build.py`: the generator.
|
||||
|
||||
## Rebuilding
|
||||
|
||||
```sh
|
||||
python3 scripts/knowledge/build.py
|
||||
```
|
||||
|
||||
The script downloads the official sources, rewrites the three JSON files and
|
||||
`sources.json`, and refreshes the license files. The generated data is committed
|
||||
so the binary needs no network at runtime. Review the diff before committing:
|
||||
the result is a new pack version.
|
||||
|
||||
## How it is used
|
||||
|
||||
The read-only `knowledge_lookup` tool is available to the planner and the
|
||||
workers. It accepts a `source`, a `query` (an id such as `T1190`,
|
||||
`WSTG-ATHN-01`, `CWE-79`, or keywords) and an optional `limit` (default 5, max
|
||||
20), and returns the matching entries. It reads the embedded pack, never the
|
||||
network.
|
||||
|
||||
## What it is not
|
||||
|
||||
- Not a training corpus, not a fine-tuning dataset, not a RAG dump.
|
||||
- No exploit code, no scraped lab writeups, no vendor-specific material.
|
||||
- Not the place for dynamic feeds (CISA KEV, NVD, OSV). Those change daily and
|
||||
belong to a fetch-at-runtime layer, not to a committed pack.
|
||||
- Descriptions are capped for tool output; open the entry URL for the full text.
|
||||
File diff suppressed because it is too large
Load Diff
+10527
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"generated_at": "2026-11-24",
|
||||
"sources": [
|
||||
{
|
||||
"source": "attack",
|
||||
"title": "MITRE ATT&CK Enterprise",
|
||||
"license": "MITRE ATT&CK Terms of Use",
|
||||
"license_url": "https://raw.githubusercontent.com/mitre-attack/attack-stix-data/master/LICENSE.txt",
|
||||
"source_url": "https://raw.githubusercontent.com/mitre-attack/attack-stix-data/master/enterprise-attack/enterprise-attack.json",
|
||||
"retrieved_at": "2026-11-24",
|
||||
"sha256": "539a843a7b53ed9749740b2123dddae3726b1a4831841c32aca740b011b910b5",
|
||||
"entries": 706,
|
||||
"data_file": "data/attack.json"
|
||||
},
|
||||
{
|
||||
"source": "wstg",
|
||||
"title": "OWASP Web Security Testing Guide",
|
||||
"license": "CC-BY-SA-4.0",
|
||||
"license_url": "https://raw.githubusercontent.com/OWASP/wstg/master/LICENSE",
|
||||
"source_url": "https://raw.githubusercontent.com/OWASP/wstg/master/checklists/checklist.json",
|
||||
"retrieved_at": "2026-11-24",
|
||||
"sha256": "c87aaa4566b6dae46e217b2630eb0c4eed9ff8317d094bc9dd2a22e8c19cb21c",
|
||||
"entries": 133,
|
||||
"data_file": "data/wstg.json"
|
||||
},
|
||||
{
|
||||
"source": "cwe",
|
||||
"title": "MITRE Common Weakness Enumeration",
|
||||
"license": "MITRE CWE Terms of Use",
|
||||
"license_url": "https://cwe.mitre.org/about/termsofuse.html",
|
||||
"source_url": "https://cwe.mitre.org/data/csv/1000.csv",
|
||||
"retrieved_at": "2026-11-24",
|
||||
"sha256": "b3b8fc1bb6e2398ce4f1a7b0f5f74949f6cd568a26190d203e1103c3aafa6ff5",
|
||||
"entries": 956,
|
||||
"data_file": "data/cwe.json"
|
||||
}
|
||||
]
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,242 @@
|
||||
// Package knowledge embeds a small, attributed security taxonomy pack used by
|
||||
// the planner and worker tools. The pack is generated from the official sources
|
||||
// by scripts/knowledge/build.py; it is not a training corpus and contains no
|
||||
// scraped lab material.
|
||||
package knowledge
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"sort"
|
||||
"strings"
|
||||
"sync"
|
||||
)
|
||||
|
||||
//go:embed data/attack.json data/wstg.json data/cwe.json
|
||||
var dataFS embed.FS
|
||||
|
||||
// Entry is one taxonomy record. Descriptions are capped by the build script;
|
||||
// Truncated marks that the full text is at URL.
|
||||
type Entry struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Category []string `json:"category,omitempty"`
|
||||
Status string `json:"status,omitempty"`
|
||||
Description string `json:"description,omitempty"`
|
||||
Truncated bool `json:"truncated,omitempty"`
|
||||
URL string `json:"url,omitempty"`
|
||||
}
|
||||
|
||||
// SourceInfo describes one embedded source. The data files keep their own
|
||||
// licenses; see knowledge/NOTICE and knowledge/licenses.
|
||||
type SourceInfo struct {
|
||||
Source string `json:"source"`
|
||||
Title string `json:"title"`
|
||||
License string `json:"license"`
|
||||
LicenseURL string `json:"license_url"`
|
||||
SourceURL string `json:"source_url"`
|
||||
RetrievedAt string `json:"retrieved_at"`
|
||||
Entries int `json:"entries"`
|
||||
}
|
||||
|
||||
type source struct {
|
||||
info SourceInfo
|
||||
entries []Entry
|
||||
byID map[string]int
|
||||
}
|
||||
|
||||
// Pack is the loaded knowledge pack.
|
||||
type Pack struct {
|
||||
sources map[string]*source
|
||||
names []string
|
||||
}
|
||||
|
||||
var (
|
||||
defaultOnce sync.Once
|
||||
defaultPack *Pack
|
||||
defaultErr error
|
||||
)
|
||||
|
||||
// Default returns the embedded pack, loading it once. A malformed embedded pack
|
||||
// is a build error, not a runtime condition; the error is returned so a caller
|
||||
// can fail at startup.
|
||||
func Default() (*Pack, error) {
|
||||
defaultOnce.Do(func() { defaultPack, defaultErr = Load() })
|
||||
return defaultPack, defaultErr
|
||||
}
|
||||
|
||||
// Load parses the embedded sources. It is exported for tests and for callers
|
||||
// that want to fail before the first lookup.
|
||||
func Load() (*Pack, error) {
|
||||
p := &Pack{sources: map[string]*source{}}
|
||||
for _, name := range []string{"attack", "wstg", "cwe"} {
|
||||
raw, err := dataFS.ReadFile("data/" + name + ".json")
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("knowledge: read %s: %w", name, err)
|
||||
}
|
||||
var file struct {
|
||||
Source string `json:"source"`
|
||||
Title string `json:"title"`
|
||||
License string `json:"license"`
|
||||
LicenseURL string `json:"license_url"`
|
||||
SourceURL string `json:"source_url"`
|
||||
RetrievedAt string `json:"retrieved_at"`
|
||||
Entries []Entry `json:"entries"`
|
||||
}
|
||||
if err := json.Unmarshal(raw, &file); err != nil {
|
||||
return nil, fmt.Errorf("knowledge: parse %s: %w", name, err)
|
||||
}
|
||||
if file.Source != name {
|
||||
return nil, fmt.Errorf("knowledge: %s.json declares source %q", name, file.Source)
|
||||
}
|
||||
if len(file.Entries) == 0 {
|
||||
return nil, fmt.Errorf("knowledge: %s has no entries", name)
|
||||
}
|
||||
s := &source{
|
||||
info: SourceInfo{
|
||||
Source: file.Source,
|
||||
Title: file.Title,
|
||||
License: file.License,
|
||||
LicenseURL: file.LicenseURL,
|
||||
SourceURL: file.SourceURL,
|
||||
RetrievedAt: file.RetrievedAt,
|
||||
Entries: len(file.Entries),
|
||||
},
|
||||
entries: file.Entries,
|
||||
byID: make(map[string]int, len(file.Entries)),
|
||||
}
|
||||
for i, e := range file.Entries {
|
||||
id := strings.ToUpper(strings.TrimSpace(e.ID))
|
||||
if id == "" || strings.TrimSpace(e.Name) == "" {
|
||||
return nil, fmt.Errorf("knowledge: %s has an entry without id or name", name)
|
||||
}
|
||||
if _, exists := s.byID[id]; exists {
|
||||
return nil, fmt.Errorf("knowledge: %s has duplicate id %s", name, id)
|
||||
}
|
||||
s.byID[id] = i
|
||||
}
|
||||
p.sources[name] = s
|
||||
p.names = append(p.names, name)
|
||||
}
|
||||
sort.Strings(p.names)
|
||||
return p, nil
|
||||
}
|
||||
|
||||
// SourceNames returns the embedded source names in stable order.
|
||||
func (p *Pack) SourceNames() []string {
|
||||
if p == nil {
|
||||
return nil
|
||||
}
|
||||
out := make([]string, len(p.names))
|
||||
copy(out, p.names)
|
||||
return out
|
||||
}
|
||||
|
||||
// SourceInfo returns the metadata for one source.
|
||||
func (p *Pack) SourceInfo(name string) (SourceInfo, bool) {
|
||||
if p == nil {
|
||||
return SourceInfo{}, false
|
||||
}
|
||||
s, ok := p.sources[strings.ToLower(strings.TrimSpace(name))]
|
||||
if !ok {
|
||||
return SourceInfo{}, false
|
||||
}
|
||||
return s.info, true
|
||||
}
|
||||
|
||||
// Lookup returns the entry with the exact id in one source.
|
||||
func (p *Pack) Lookup(source, id string) (Entry, bool) {
|
||||
if p == nil {
|
||||
return Entry{}, false
|
||||
}
|
||||
s, ok := p.sources[strings.ToLower(strings.TrimSpace(source))]
|
||||
if !ok {
|
||||
return Entry{}, false
|
||||
}
|
||||
i, ok := s.byID[strings.ToUpper(strings.TrimSpace(id))]
|
||||
if !ok {
|
||||
return Entry{}, false
|
||||
}
|
||||
return s.entries[i], true
|
||||
}
|
||||
|
||||
// Search returns up to limit matches for query in one source and the total
|
||||
// number of matches before the limit. An exact id wins and returns one entry.
|
||||
func (p *Pack) Search(source, query string, limit int) ([]Entry, int, error) {
|
||||
if p == nil {
|
||||
return nil, 0, fmt.Errorf("knowledge pack is not loaded")
|
||||
}
|
||||
s, ok := p.sources[strings.ToLower(strings.TrimSpace(source))]
|
||||
if !ok {
|
||||
return nil, 0, fmt.Errorf("unknown knowledge source %q (valid: %s)", source, strings.Join(p.names, ", "))
|
||||
}
|
||||
q := strings.TrimSpace(query)
|
||||
if q == "" {
|
||||
return nil, 0, fmt.Errorf("query is required")
|
||||
}
|
||||
if i, ok := s.byID[strings.ToUpper(q)]; ok {
|
||||
return []Entry{s.entries[i]}, 1, nil
|
||||
}
|
||||
tokens := strings.Fields(strings.ToLower(q))
|
||||
if len(tokens) == 0 {
|
||||
return nil, 0, fmt.Errorf("query is required")
|
||||
}
|
||||
type hit struct {
|
||||
entry Entry
|
||||
score int
|
||||
}
|
||||
hits := make([]hit, 0, 16)
|
||||
lowerQuery := strings.ToLower(q)
|
||||
for _, e := range s.entries {
|
||||
hay := strings.ToLower(strings.Join([]string{
|
||||
e.ID, e.Name, strings.Join(e.Category, " "), e.Status, e.Description,
|
||||
}, " "))
|
||||
if !containsAll(hay, tokens) {
|
||||
continue
|
||||
}
|
||||
score := 1
|
||||
name := strings.ToLower(e.Name)
|
||||
id := strings.ToLower(e.ID)
|
||||
switch {
|
||||
case strings.HasPrefix(name, lowerQuery):
|
||||
score += 4
|
||||
case strings.Contains(name, lowerQuery):
|
||||
score += 3
|
||||
}
|
||||
if strings.HasPrefix(id, strings.ToUpper(q)) {
|
||||
score += 2
|
||||
}
|
||||
hits = append(hits, hit{entry: e, score: score})
|
||||
}
|
||||
sort.SliceStable(hits, func(i, j int) bool {
|
||||
if hits[i].score != hits[j].score {
|
||||
return hits[i].score > hits[j].score
|
||||
}
|
||||
return hits[i].entry.ID < hits[j].entry.ID
|
||||
})
|
||||
total := len(hits)
|
||||
if limit <= 0 {
|
||||
limit = 5
|
||||
}
|
||||
if limit > 20 {
|
||||
limit = 20
|
||||
}
|
||||
if len(hits) > limit {
|
||||
hits = hits[:limit]
|
||||
}
|
||||
out := make([]Entry, len(hits))
|
||||
for i := range hits {
|
||||
out[i] = hits[i].entry
|
||||
}
|
||||
return out, total, nil
|
||||
}
|
||||
|
||||
func containsAll(hay string, tokens []string) bool {
|
||||
for _, token := range tokens {
|
||||
if !strings.Contains(hay, token) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
package knowledge
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func load(t *testing.T) *Pack {
|
||||
t.Helper()
|
||||
p, err := Load()
|
||||
if err != nil {
|
||||
t.Fatalf("Load: %v", err)
|
||||
}
|
||||
return p
|
||||
}
|
||||
|
||||
func TestLoadSources(t *testing.T) {
|
||||
p := load(t)
|
||||
names := p.SourceNames()
|
||||
if len(names) != 3 {
|
||||
t.Fatalf("sources = %v, want attack, cwe, wstg", names)
|
||||
}
|
||||
want := map[string]int{"attack": 600, "wstg": 100, "cwe": 900}
|
||||
for _, name := range names {
|
||||
info, ok := p.SourceInfo(name)
|
||||
if !ok {
|
||||
t.Fatalf("SourceInfo(%q) missing", name)
|
||||
}
|
||||
if info.Entries < want[name] {
|
||||
t.Errorf("%s entries = %d, want at least %d", name, info.Entries, want[name])
|
||||
}
|
||||
if info.License == "" || info.SourceURL == "" || info.RetrievedAt == "" {
|
||||
t.Errorf("%s metadata incomplete: %+v", name, info)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestLookupExact(t *testing.T) {
|
||||
p := load(t)
|
||||
cases := []struct {
|
||||
source, id, name string
|
||||
}{
|
||||
{"attack", "T1190", "Exploit Public-Facing Application"},
|
||||
{"wstg", "WSTG-ATHN-01", "Default Credentials"},
|
||||
{"cwe", "CWE-79", "Improper Neutralization of Input During Web Page Generation"},
|
||||
}
|
||||
for _, c := range cases {
|
||||
e, ok := p.Lookup(c.source, c.id)
|
||||
if !ok {
|
||||
t.Fatalf("%s %s not found", c.source, c.id)
|
||||
}
|
||||
if e.Name != c.name {
|
||||
t.Errorf("%s name = %q, want %q", c.id, e.Name, c.name)
|
||||
}
|
||||
if e.URL == "" {
|
||||
t.Errorf("%s has no url", c.id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestLookupIsCaseInsensitiveAndTrimmed(t *testing.T) {
|
||||
p := load(t)
|
||||
for _, id := range []string{"t1190", " T1190 ", "T1190"} {
|
||||
if _, ok := p.Lookup("ATTACK", id); !ok {
|
||||
t.Errorf("Lookup(ATTACK, %q) not found", id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestSearchKeyword(t *testing.T) {
|
||||
p := load(t)
|
||||
matches, total, err := p.Search("wstg", "default credentials", 5)
|
||||
if err != nil {
|
||||
t.Fatalf("Search: %v", err)
|
||||
}
|
||||
if total == 0 || len(matches) == 0 {
|
||||
t.Fatal("no matches for default credentials")
|
||||
}
|
||||
if matches[0].ID != "WSTG-ATHN-01" {
|
||||
t.Errorf("first match = %s, want WSTG-ATHN-01", matches[0].ID)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSearchExactIDWins(t *testing.T) {
|
||||
p := load(t)
|
||||
matches, total, err := p.Search("cwe", "cwe-79", 5)
|
||||
if err != nil {
|
||||
t.Fatalf("Search: %v", err)
|
||||
}
|
||||
if total != 1 || len(matches) != 1 || matches[0].ID != "CWE-79" {
|
||||
t.Fatalf("matches=%v total=%d, want one CWE-79", matches, total)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSearchLimit(t *testing.T) {
|
||||
p := load(t)
|
||||
matches, total, err := p.Search("cwe", "data", 2)
|
||||
if err != nil {
|
||||
t.Fatalf("Search: %v", err)
|
||||
}
|
||||
if len(matches) != 2 {
|
||||
t.Fatalf("len(matches) = %d, want 2", len(matches))
|
||||
}
|
||||
if total <= 2 {
|
||||
t.Fatalf("total = %d, want more than the limit", total)
|
||||
}
|
||||
matches, _, err = p.Search("cwe", "data", 100)
|
||||
if err != nil {
|
||||
t.Fatalf("Search: %v", err)
|
||||
}
|
||||
if len(matches) > 20 {
|
||||
t.Fatalf("limit was not clamped: %d", len(matches))
|
||||
}
|
||||
}
|
||||
|
||||
func TestSearchErrors(t *testing.T) {
|
||||
p := load(t)
|
||||
if _, _, err := p.Search("nope", "x", 5); err == nil || !strings.Contains(err.Error(), "unknown knowledge source") {
|
||||
t.Fatalf("unknown source error = %v", err)
|
||||
}
|
||||
if _, _, err := p.Search("attack", " ", 5); err == nil || !strings.Contains(err.Error(), "query is required") {
|
||||
t.Fatalf("empty query error = %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestEveryEntryHasNameAndURL(t *testing.T) {
|
||||
p := load(t)
|
||||
for _, name := range p.SourceNames() {
|
||||
for _, e := range p.sources[name].entries {
|
||||
if strings.TrimSpace(e.ID) == "" || strings.TrimSpace(e.Name) == "" {
|
||||
t.Fatalf("%s has an entry without id or name: %+v", name, e)
|
||||
}
|
||||
if strings.TrimSpace(e.URL) == "" {
|
||||
t.Fatalf("%s %s has no url", name, e.ID)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
License
|
||||
-------
|
||||
The MITRE Corporation (MITRE) hereby grants you a non-exclusive, royalty-free license to use ATT&CK® for research,
|
||||
development, and commercial purposes. Any copy you make for such purposes is authorized provided that you reproduce
|
||||
MITRE's copyright designation and this license in any such copy.
|
||||
|
||||
"© 2026 The MITRE Corporation. This work is reproduced and distributed with the permission of The MITRE Corporation."
|
||||
|
||||
Disclaimers
|
||||
-----------
|
||||
MITRE does not claim ATT&CK enumerates all possibilities for the types of actions and behaviors documented as part
|
||||
of its adversary model and framework of techniques. Using the information contained within ATT&CK to address or cover
|
||||
full categories of techniques will not guarantee full defensive coverage as there may be undisclosed techniques or
|
||||
variations on existing techniques not documented by ATT&CK.
|
||||
|
||||
ALL DOCUMENTS AND THE INFORMATION CONTAINED THEREIN ARE PROVIDED ON AN "AS IS" BASIS AND THE CONTRIBUTOR, THE
|
||||
ORGANIZATION HE/SHE REPRESENTS OR IS SPONSORED BY (IF ANY), THE MITRE CORPORATION, ITS BOARD OF TRUSTEES, OFFICERS,
|
||||
AGENTS, AND EMPLOYEES, DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT
|
||||
THE USE OF THE INFORMATION THEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
@@ -0,0 +1,282 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<?xml version="1.0"?>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
||||
<meta name="description" content="Common Weakness Enumeration (CWE) is a list of software and hardware weaknesses." />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=Edge">
|
||||
<link rel="shortcut icon" href="/favicon.ico" />
|
||||
<link href="/css/main.css?version=5.0.102726" rel="stylesheet" type="text/css" />
|
||||
<link href="/css/custom.css" rel="stylesheet" type="text/css" />
|
||||
<!--[if IE]>
|
||||
<link rel="stylesheet" type="text/css" href="/css/ie.css?version=1.7" />
|
||||
<![endif]-->
|
||||
|
||||
<script src="/includes/custom_filter.js" language="JavaScript" type="text/javascript"></script>
|
||||
<script src="/includes/browserheight.js" language="JavaScript" type="text/javascript"></script>
|
||||
<script src="/includes/jquery.js" language="JavaScript" type="text/javascript"></script>
|
||||
<script src="/includes/cwe_minimizer.js?version=4.12.062923" language="JavaScript" type="text/javascript"></script>
|
||||
<script src="/includes/cookie.js?version=4.12.062923" language="Javascript" type="text/javascript"></script>
|
||||
<script src="/includes/includeglossarydef.js" language="JavaScript" type="text/javascript"></script>
|
||||
<script src="/includes/custom.js" language="JavaScript" type="text/javascript"></script>
|
||||
<script src=https://cmp.osano.com/AzyhULTdPkqmy4aDN/318aa814-0420-45bb-857d-8fb5fac33ff8/osano.js></script>
|
||||
<link href="/css/print.css?version=1.11" rel="stylesheet" media="print" type="text/css" />
|
||||
<link href="/css/mappingonly.css" rel="stylesheet" type="text/css" />
|
||||
<noscript>
|
||||
<style type="text/css">
|
||||
#script { visibility:collapse; visibility:hidden; font-size:0px; height:0px; width:0px }
|
||||
#noscript { visibility:visible; font-size:inherit; height:inherit; width:inherit}
|
||||
</style>
|
||||
</noscript>
|
||||
<title>CWE -
|
||||
Terms of Use</title>
|
||||
</head>
|
||||
<body onload="onloadCookie()">
|
||||
<a name="top" id="top"></a>
|
||||
<div id="MastHead" style="width:100%">
|
||||
|
||||
<div style="width:62%;float:left;padding-top:15px;padding-left:10px;padding-bottom:2px;">
|
||||
<a href="/index.html" style="color:#32498D; text-decoration:none">
|
||||
<img src="/images/cwe-20years-logo.png" width="203" height="58" style="float:left;border:0;margin-right:6px" alt="CWE" />
|
||||
<h1 style="color:#314a8d;font-size:1.5em;font-family:'Verdana',sans-serif;#eee;margin: .1em auto">Common Weakness Enumeration</h1>
|
||||
<p style="color:#314a8d;font-family:'Times New Roman';font-style:italic;font-size:1em;#eee;margin:.1em auto 0 auto">Celebrating 20 years of community-developed cybersecurity weakness knowledge!</p>
|
||||
</a>
|
||||
</div>
|
||||
<div style="float:right;padding-top:0px;text-align:right;padding-left:8px;padding-right:4px;padding-bottom:0px;"><a href="/about/new_to_cwe.html" title="New to CWE click here logo"><img src="/images/new_to_cwe/new_to_cwe_click_here.png" height="90" border="0" alt="New to CWE? click here!" style="text-align:center"/></a></div>
|
||||
<div style="float:right;padding-top:0px;text-align:right;padding-left:0px;padding-right:4px;padding-bottom:0px;"><a href="/topHW/index.html" title="CWE Most Important Hardware Weaknesses"> <img src="/images/mihw_logo.svg" width="90" border="0" alt="CWE Most Important Hardware Weaknesses" style="vertical-align:bottom"/></a></div>
|
||||
<div style="float:right;padding-top:0px;text-align:right;padding-left:0px;padding-right:4px;padding-bottom:0px;"><a href="/top25/" title="CWE Top 25"><img src="/images/cwe_top_25_logo_simple.svg" width="90" border="0" alt="CWE Top 25 Most Dangerous Weaknesses" style="vertical-align:bottom"/></a></div>
|
||||
|
||||
</div><!--End Masthead div-->
|
||||
|
||||
|
||||
<div id="HeaderBar" class="noprint">
|
||||
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
||||
<tr>
|
||||
<td width="100%" align="left" style="padding-left:10px; font-size:75%;">
|
||||
<a href="/" >Home</a> > <a href="/about/index.html" >About CWE</a> >
|
||||
|
||||
Terms of Use
|
||||
|
||||
</td>
|
||||
<td align="right" nowrap="nowrap" style="padding-right:12px">
|
||||
<!-- Begin /includes/search_cwe_id.html -->
|
||||
<div class="noprint">
|
||||
<form action="/cgi-bin/jumpmenu.cgi" align="right" style="padding:0px; margin:0px">
|
||||
ID <label for="id" style="padding-right:5px">Lookup:</label>
|
||||
<input id="id" name="id" type="text" style="width:50px; font-size:80%" maxlength="10" />
|
||||
<input value="Go" style="padding: 0px; font-size:80%" type="submit">
|
||||
</form>
|
||||
</div>
|
||||
<!-- End /includes/search_cwe_id.html -->
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div> <!--//HeaderBar-->
|
||||
<div class="yesprint">
|
||||
<hr width="100%" size="1" style="clear:both" color="#000000" />
|
||||
</div>
|
||||
|
||||
<div class="topnav">
|
||||
<ul>
|
||||
<li><a href="/index.html">Home</a></li>
|
||||
<li>
|
||||
<div class="dropdown">
|
||||
<button class="dropbtn">About ▼</button>
|
||||
<div class="dropdown-content">
|
||||
<a href="/about/index.html">Who We Are</a>
|
||||
<a href="/about/user_stories.html">User Stories</a>
|
||||
<a href="/about/history.html">History</a>
|
||||
<a href="/about/documents.html">Documents</a>
|
||||
<a href="/about/cwe_videos.html">Videos</a>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div class="dropdown">
|
||||
<button class="dropbtn">Learn ▼</button>
|
||||
<div class="dropdown-content">
|
||||
<a href="/about/new_to_cwe.html">Basics</a>
|
||||
<div class="dropdown-sub-group">
|
||||
<a href="/documents/cwe_usage/guidance.html">Root Cause Mapping ►</a>
|
||||
<div class="dropdown-content-submenu">
|
||||
<a href="/documents/cwe_usage/guidance.html">Guidance</a>
|
||||
<a href="/documents/cwe_usage/quick_tips.html">Quick Tips</a>
|
||||
<a href="/documents/cwe_usage/mapping_examples.html">Examples</a>
|
||||
</div>
|
||||
</div>
|
||||
<a href="/community/submissions/overview.html">How to Contribute Weakness Content</a>
|
||||
<a href="/about/faq.html">FAQs</a>
|
||||
<a href="/documents/glossary/index.html">Glossary</a>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div class="dropdown">
|
||||
<button class="dropbtn">Access Content ▼</button>
|
||||
<div class="dropdown-content">
|
||||
<div class="dropdown-sub-group">
|
||||
<a href="/scoring/index.html#top_n_lists">Top-N Lists ►</a>
|
||||
<div class="dropdown-content-submenu">
|
||||
<a href="/top25/">Top 25 Software</a>
|
||||
<a href="/topHW/index.html">Top Hardware</a>
|
||||
<a href="/top25/archive/2025/2025_kev_list.html">Top 10 KEV Weaknesses</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="dropdown-sub-group">
|
||||
<a href="/data/index.html">CWE List ►</a>
|
||||
<div class="dropdown-content-submenu">
|
||||
<a href="/data/index.html">Current Version</a>
|
||||
<a href="/data/reports.html">Reports</a>
|
||||
<a href="/data/pdfs.html">Visualizations</a>
|
||||
<a href="/data/archive.html">Releases Archive</a>
|
||||
</div>
|
||||
</div>
|
||||
<a href="/data/downloads.html">Downloads</a>
|
||||
<a href="https://github.com/CWE-CAPEC/REST-API-wg/blob/main/Quick%20Start.md" target="_blank">REST API</a>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div class="dropdown">
|
||||
<button class="dropbtn">Community ▼</button>
|
||||
<div class="dropdown-content">
|
||||
<div class="dropdown-sub-group">
|
||||
<a href="/news/">News ►</a>
|
||||
<div class="dropdown-content-submenu">
|
||||
<a href="/news/archives/news2026.html">Current News</a>
|
||||
<a href="https://medium.com/@CWE_CAPEC" target="_blank">Blog</a>
|
||||
<a href="/news/podcast.html">Podcast</a>
|
||||
<a href="/news/archives/index.html">News Archive</a>
|
||||
</div>
|
||||
</div>
|
||||
<a href="/community/board.html">CWE Board</a>
|
||||
<a href="/community/working_groups.html">Working Groups & Special Interest Groups</a>
|
||||
<a href="/community/registration.html">Email Lists</a>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div class="dropdown">
|
||||
<button class="dropbtn">Search ▼</button>
|
||||
<div class="dropdown-content">
|
||||
<a href="/">Search CWE List</a>
|
||||
<a href="/find/index.html">Search Website</a>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
||||
<table width="100%" border="0" cellspacing="0" cellpadding="0" id="MainPane">
|
||||
<tr>
|
||||
<!-- begin left side menu -->
|
||||
<td valign="top" rowspan="2" id="LeftPane">
|
||||
<!--include virtual="/includes/leftsidemenu.html" Removed 11212016-->
|
||||
<script type="text/javascript">browserheight();</script>
|
||||
</td>
|
||||
<!-- end left side menu -->
|
||||
<td style="height:1px"></td>
|
||||
<!-- begin right column -->
|
||||
<td valign="top" align="center" rowspan="2" nowrap="nowrap" id="RightPane">
|
||||
|
||||
|
||||
</td>
|
||||
<!-- end right side menu -->
|
||||
</tr>
|
||||
<tr>
|
||||
<!-- begin content pane -->
|
||||
<td valign="top" width="100%" id="Contentpane">
|
||||
|
||||
<!--Glossary tags-->
|
||||
|
||||
<div id="styled_popup" name="styled_popup" style="display:none; position:fixed; top:300; height:auto; width:300px; z-index:1000">
|
||||
<table width="300" cellpadding="0" cellspacing="0" border="0" style="border:1px solid #32498D;">
|
||||
<tr style="background-color:#32498D; color:#ffffff;">
|
||||
<td width="100%" style="padding:1px 5px 1px 5px; border-bottom:1px solid #000000"><div width="100%" style="font-weight:bold;">CWE Glossary Definition</div></td>
|
||||
<td nowrap="nowrap" style="padding:1px; border-bottom:1px solid #000000" valign="top"><a href="javascript:styledPopupClose();"><img src="/images/layout/close.gif" border="0" alt="x"></a></td>
|
||||
</tr>
|
||||
<tr><td colspan="2" style="background: url(/images/layout/ylgradient.jpg); background-repeat: repeat-x repeat-y; padding:5px; background-color:#FFFFCC; " valign="top">
|
||||
<div id="output" style="max-height:400px; overflow-y:auto"></div>
|
||||
</td></tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
|
||||
<!--begin Main Content-->
|
||||
<h2>Terms of Use</h2>
|
||||
<p>CWE™ is free to use by any organization or individual for any research, development, and/or commercial purposes, per these CWE Terms of Use. Accordingly, The MITRE Corporation hereby grants you a non-exclusive, royalty-free license to use CWE for research, development, and commercial purposes. Any copy you make for such purposes is authorized on the condition that you reproduce MITRE’s copyright designation and this license in any such copy. CWE is a trademark of The MITRE Corporation. Please contact cwe@mitre.org if you require further clarification on this issue.</p>
|
||||
|
||||
<h3>DISCLAIMERS</h3>
|
||||
|
||||
<p>By accessing information through this site you (as “the user”) hereby agrees the site and the information is provided on an “as is” basis only without warranty of any kind, express or implied, including but not limited to implied warranties of merchantability, availability, accuracy, noninfringement, or fitness for a particular purpose. Use of this site and the information is at the user’s own risk. The user shall comply with all applicable laws, rules, and regulations, and the data source’s restrictions, when using the site.</p>
|
||||
|
||||
<p>By contributing information to this site you (as “the contributor”) hereby represents and warrants the contributor has obtained all necessary permissions from copyright holders and other third parties to allow the contributor to contribute, and this site to host and display, the information and any such contribution, hosting, and displaying will not violate any law, rule, or regulation. Additionally, the contributor hereby grants all users of such information a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable license to reproduce, prepare derivative works of, publicly display, publicly perform, sublicense, and distribute such information and all derivative works.</p>
|
||||
|
||||
<p>The MITRE Corporation expressly disclaims any liability for any damages arising from the contributor’s contribution of such information, the user’s use of the site or such information, and The MITRE Corporation’s hosting the tool and displaying the information. The foregoing disclaimer specifically includes but is not limited to general, consequential, indirect, incidental, exemplary, or special or punitive damages (including but not limited to loss of income, program interruption, loss of information, or other pecuniary loss) arising out of use of this information, no matter the cause of action, even if The MITRE Corporation has been advised of the possibility of such damages.</p>
|
||||
|
||||
<!--end Main Content-->
|
||||
|
||||
</td>
|
||||
<!-- end content pane -->
|
||||
</tr>
|
||||
</table>
|
||||
<div id="FootPane" class="noprint">
|
||||
<div id="footbar">
|
||||
<b>Page Last Updated: </b>
|
||||
|
||||
July 20, 2023
|
||||
</div>
|
||||
<div class="Footer noprint">
|
||||
<a name="footer" id="footer"></a>
|
||||
<table width="100%" cellpadding="0" cellspacing="0" border="0" class="ltgreybackground" style="clear:both">
|
||||
<tr>
|
||||
<td colspan="3" id="line"><div class="line"> </div></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="middle" nowrap="nowrap">
|
||||
<div id="footerlinks" class="footlogo">
|
||||
<a href="http://www.mitre.org" target="_blank" rel="noopener noreferrer"><img src="/images/mitre_logo.gif" height="36" border="0" alt="MITRE" title="MITRE"/></a>
|
||||
</div>
|
||||
</td>
|
||||
<td width="100%" valign="top" style="padding:6px 0px;">
|
||||
<div id="footerlinks">
|
||||
<a href="/sitemap.html">Site Map</a> |
|
||||
<a href="/about/termsofuse.html">Terms of Use</a> |
|
||||
<a href="#" onclick="Osano.cm.showDrawer('osano-cm-dom-info-dialog-open')">Manage Cookies</a> |
|
||||
<a href="/about/cookie_notice.html">Cookie Notice</a> |
|
||||
<a href="/about/privacy_policy.html">Privacy Policy</a> |
|
||||
<a href="mailto:cwe@mitre.org">Contact Us</a> |
|
||||
<a target="_blank" href="https://x.com/CweCapec"><img src="/images/x-logo-black.png" width="18" height="18" style="border:0;vertical-align:right;" alt="CWE on X" title="CWE on X"></a>
|
||||
<a target="_blank" href="https://www.linkedin.com/showcase/cve-cwe-capec"><img src="/images/linkedin_sm.jpg" width="20" height="20" style="border:0;vertical-align:right;" alt="CWE on LinkedIn" title="CWE on LinkedIn"></a>
|
||||
<a target="_blank" href="https://bsky.app/profile/cweprogram.bsky.social"><img src="/images/bluesky_logo_sm.png" width="18" height="18" style="border:0;vertical-align:right;" alt="CWE on Bluesky" title="Bluesky"></a>
|
||||
<a target="_blank" href="https://mastodon.social/@CWE_Program"><img src="/images/mastodon-logo.png" width="20" height="20" style="border:0;vertical-align:right;" alt="CWE on Mastodon" title="CWE on Mastodon"></a>
|
||||
<a target="_blank" href="https://www.youtube.com/channel/UCpY9VIpRmFK4ebD6orssifA"><img src="/images/youtube.png" width="20" height="20" style="border:0;vertical-align:right;" alt="CWE YouTube channel" title="CWE YouTube Channel"></a>
|
||||
<a href="/news/podcast.html"><img src="/images/out_of_bounds_read_logo.png" width="22" height="22" style="border:0;vertical-align:right;" alt="CWE Out-of-Bounds-Read Podcast" title="CWE Out-of-Bounds-Read Podcast"></a>
|
||||
<a target="_blank" href="https://medium.com/@CWE_CAPEC"><img src="/images/medium.png" width="20" height="20" style="border:0;vertical-align:right;" alt="CWE Blog on Medium blog" title="CWE Blog on Medium"></a>
|
||||
</div>
|
||||
<p>Use of the Common Weakness Enumeration (CWE™) and the associated references from this website are subject to the <a href="/about/termsofuse.html">Terms of Use</a>. CWE is sponsored by the <a target="_blank" rel="noopener noreferrer" href="https://www.dhs.gov/">U.S. Department of Homeland Security</a> (DHS) <a target="_blank" rel="noopener noreferrer" href="https://www.dhs.gov/cisa/cybersecurity-division">Cybersecurity and Infrastructure Security Agency</a> (CISA) and managed by the <a href="https://www.dhs.gov/science-and-technology/hssedi" target="_blank" rel="noopener noreferrer">Homeland Security Systems Engineering and Development Institute</a> (HSSEDI) which is operated by <a target="_blank" rel="noopener noreferrer" href="http://www.mitre.org/">The MITRE Corporation</a> (MITRE). Copyright © 2006–2026, The MITRE Corporation. CWE, CWSS, CWRAF, and the CWE logo are trademarks of The MITRE Corporation.</p>
|
||||
</td>
|
||||
<td valign="middle" nowrap="nowrap">
|
||||
<div id="footerlinks" class="footlogo">
|
||||
<a href="https://www.dhs.gov/science-and-technology/hssedi" target="_blank" rel="noopener noreferrer"><img src="/images/hssedi.png" height="36" border="0" alt="HSSEDI" title="HSSEDI"/></a>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Google tag (gtag.js) -->
|
||||
<script async src="https://www.googletagmanager.com/gtag/js?id=G-TCLW30GNGV"></script>
|
||||
<script>
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag(){dataLayer.push(arguments);}
|
||||
gtag('js', new Date());
|
||||
|
||||
gtag('config', 'G-TCLW30GNGV');
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
CWE™ is free to use by any organization or individual for any research,
|
||||
development, and/or commercial purposes, per these CWE Terms of Use.
|
||||
Accordingly, The MITRE Corporation hereby grants you a non-exclusive,
|
||||
royalty-free license to use CWE for research, development, and commercial
|
||||
purposes. Any copy you make for such purposes is authorized on the condition
|
||||
that you reproduce MITRE's copyright designation and this license in any such
|
||||
copy. CWE is a trademark of The MITRE Corporation.
|
||||
|
||||
Copyright © 2006-2026, The MITRE Corporation.
|
||||
|
||||
Full terms: https://cwe.mitre.org/about/termsofuse.html
|
||||
@@ -0,0 +1 @@
|
||||
https://cwe.mitre.org/about/termsofuse.html
|
||||
@@ -0,0 +1,428 @@
|
||||
Attribution-ShareAlike 4.0 International
|
||||
|
||||
=======================================================================
|
||||
|
||||
Creative Commons Corporation ("Creative Commons") is not a law firm and
|
||||
does not provide legal services or legal advice. Distribution of
|
||||
Creative Commons public licenses does not create a lawyer-client or
|
||||
other relationship. Creative Commons makes its licenses and related
|
||||
information available on an "as-is" basis. Creative Commons gives no
|
||||
warranties regarding its licenses, any material licensed under their
|
||||
terms and conditions, or any related information. Creative Commons
|
||||
disclaims all liability for damages resulting from their use to the
|
||||
fullest extent possible.
|
||||
|
||||
Using Creative Commons Public Licenses
|
||||
|
||||
Creative Commons public licenses provide a standard set of terms and
|
||||
conditions that creators and other rights holders may use to share
|
||||
original works of authorship and other material subject to copyright
|
||||
and certain other rights specified in the public license below. The
|
||||
following considerations are for informational purposes only, are not
|
||||
exhaustive, and do not form part of our licenses.
|
||||
|
||||
Considerations for licensors: Our public licenses are
|
||||
intended for use by those authorized to give the public
|
||||
permission to use material in ways otherwise restricted by
|
||||
copyright and certain other rights. Our licenses are
|
||||
irrevocable. Licensors should read and understand the terms
|
||||
and conditions of the license they choose before applying it.
|
||||
Licensors should also secure all rights necessary before
|
||||
applying our licenses so that the public can reuse the
|
||||
material as expected. Licensors should clearly mark any
|
||||
material not subject to the license. This includes other CC-
|
||||
licensed material, or material used under an exception or
|
||||
limitation to copyright. More considerations for licensors:
|
||||
wiki.creativecommons.org/Considerations_for_licensors
|
||||
|
||||
Considerations for the public: By using one of our public
|
||||
licenses, a licensor grants the public permission to use the
|
||||
licensed material under specified terms and conditions. If
|
||||
the licensor's permission is not necessary for any reason--for
|
||||
example, because of any applicable exception or limitation to
|
||||
copyright--then that use is not regulated by the license. Our
|
||||
licenses grant only permissions under copyright and certain
|
||||
other rights that a licensor has authority to grant. Use of
|
||||
the licensed material may still be restricted for other
|
||||
reasons, including because others have copyright or other
|
||||
rights in the material. A licensor may make special requests,
|
||||
such as asking that all changes be marked or described.
|
||||
Although not required by our licenses, you are encouraged to
|
||||
respect those requests where reasonable. More considerations
|
||||
for the public:
|
||||
wiki.creativecommons.org/Considerations_for_licensees
|
||||
|
||||
=======================================================================
|
||||
|
||||
Creative Commons Attribution-ShareAlike 4.0 International Public
|
||||
License
|
||||
|
||||
By exercising the Licensed Rights (defined below), You accept and agree
|
||||
to be bound by the terms and conditions of this Creative Commons
|
||||
Attribution-ShareAlike 4.0 International Public License ("Public
|
||||
License"). To the extent this Public License may be interpreted as a
|
||||
contract, You are granted the Licensed Rights in consideration of Your
|
||||
acceptance of these terms and conditions, and the Licensor grants You
|
||||
such rights in consideration of benefits the Licensor receives from
|
||||
making the Licensed Material available under these terms and
|
||||
conditions.
|
||||
|
||||
|
||||
Section 1 -- Definitions.
|
||||
|
||||
a. Adapted Material means material subject to Copyright and Similar
|
||||
Rights that is derived from or based upon the Licensed Material
|
||||
and in which the Licensed Material is translated, altered,
|
||||
arranged, transformed, or otherwise modified in a manner requiring
|
||||
permission under the Copyright and Similar Rights held by the
|
||||
Licensor. For purposes of this Public License, where the Licensed
|
||||
Material is a musical work, performance, or sound recording,
|
||||
Adapted Material is always produced where the Licensed Material is
|
||||
synched in timed relation with a moving image.
|
||||
|
||||
b. Adapter's License means the license You apply to Your Copyright
|
||||
and Similar Rights in Your contributions to Adapted Material in
|
||||
accordance with the terms and conditions of this Public License.
|
||||
|
||||
c. BY-SA Compatible License means a license listed at
|
||||
creativecommons.org/compatiblelicenses, approved by Creative
|
||||
Commons as essentially the equivalent of this Public License.
|
||||
|
||||
d. Copyright and Similar Rights means copyright and/or similar rights
|
||||
closely related to copyright including, without limitation,
|
||||
performance, broadcast, sound recording, and Sui Generis Database
|
||||
Rights, without regard to how the rights are labeled or
|
||||
categorized. For purposes of this Public License, the rights
|
||||
specified in Section 2(b)(1)-(2) are not Copyright and Similar
|
||||
Rights.
|
||||
|
||||
e. Effective Technological Measures means those measures that, in the
|
||||
absence of proper authority, may not be circumvented under laws
|
||||
fulfilling obligations under Article 11 of the WIPO Copyright
|
||||
Treaty adopted on December 20, 1996, and/or similar international
|
||||
agreements.
|
||||
|
||||
f. Exceptions and Limitations means fair use, fair dealing, and/or
|
||||
any other exception or limitation to Copyright and Similar Rights
|
||||
that applies to Your use of the Licensed Material.
|
||||
|
||||
g. License Elements means the license attributes listed in the name
|
||||
of a Creative Commons Public License. The License Elements of this
|
||||
Public License are Attribution and ShareAlike.
|
||||
|
||||
h. Licensed Material means the artistic or literary work, database,
|
||||
or other material to which the Licensor applied this Public
|
||||
License.
|
||||
|
||||
i. Licensed Rights means the rights granted to You subject to the
|
||||
terms and conditions of this Public License, which are limited to
|
||||
all Copyright and Similar Rights that apply to Your use of the
|
||||
Licensed Material and that the Licensor has authority to license.
|
||||
|
||||
j. Licensor means the individual(s) or entity(ies) granting rights
|
||||
under this Public License.
|
||||
|
||||
k. Share means to provide material to the public by any means or
|
||||
process that requires permission under the Licensed Rights, such
|
||||
as reproduction, public display, public performance, distribution,
|
||||
dissemination, communication, or importation, and to make material
|
||||
available to the public including in ways that members of the
|
||||
public may access the material from a place and at a time
|
||||
individually chosen by them.
|
||||
|
||||
l. Sui Generis Database Rights means rights other than copyright
|
||||
resulting from Directive 96/9/EC of the European Parliament and of
|
||||
the Council of 11 March 1996 on the legal protection of databases,
|
||||
as amended and/or succeeded, as well as other essentially
|
||||
equivalent rights anywhere in the world.
|
||||
|
||||
m. You means the individual or entity exercising the Licensed Rights
|
||||
under this Public License. Your has a corresponding meaning.
|
||||
|
||||
|
||||
Section 2 -- Scope.
|
||||
|
||||
a. License grant.
|
||||
|
||||
1. Subject to the terms and conditions of this Public License,
|
||||
the Licensor hereby grants You a worldwide, royalty-free,
|
||||
non-sublicensable, non-exclusive, irrevocable license to
|
||||
exercise the Licensed Rights in the Licensed Material to:
|
||||
|
||||
a. reproduce and Share the Licensed Material, in whole or
|
||||
in part; and
|
||||
|
||||
b. produce, reproduce, and Share Adapted Material.
|
||||
|
||||
2. Exceptions and Limitations. For the avoidance of doubt, where
|
||||
Exceptions and Limitations apply to Your use, this Public
|
||||
License does not apply, and You do not need to comply with
|
||||
its terms and conditions.
|
||||
|
||||
3. Term. The term of this Public License is specified in Section
|
||||
6(a).
|
||||
|
||||
4. Media and formats; technical modifications allowed. The
|
||||
Licensor authorizes You to exercise the Licensed Rights in
|
||||
all media and formats whether now known or hereafter created,
|
||||
and to make technical modifications necessary to do so. The
|
||||
Licensor waives and/or agrees not to assert any right or
|
||||
authority to forbid You from making technical modifications
|
||||
necessary to exercise the Licensed Rights, including
|
||||
technical modifications necessary to circumvent Effective
|
||||
Technological Measures. For purposes of this Public License,
|
||||
simply making modifications authorized by this Section 2(a)
|
||||
(4) never produces Adapted Material.
|
||||
|
||||
5. Downstream recipients.
|
||||
|
||||
a. Offer from the Licensor -- Licensed Material. Every
|
||||
recipient of the Licensed Material automatically
|
||||
receives an offer from the Licensor to exercise the
|
||||
Licensed Rights under the terms and conditions of this
|
||||
Public License.
|
||||
|
||||
b. Additional offer from the Licensor -- Adapted Material.
|
||||
Every recipient of Adapted Material from You
|
||||
automatically receives an offer from the Licensor to
|
||||
exercise the Licensed Rights in the Adapted Material
|
||||
under the conditions of the Adapter's License You apply.
|
||||
|
||||
c. No downstream restrictions. You may not offer or impose
|
||||
any additional or different terms or conditions on, or
|
||||
apply any Effective Technological Measures to, the
|
||||
Licensed Material if doing so restricts exercise of the
|
||||
Licensed Rights by any recipient of the Licensed
|
||||
Material.
|
||||
|
||||
6. No endorsement. Nothing in this Public License constitutes or
|
||||
may be construed as permission to assert or imply that You
|
||||
are, or that Your use of the Licensed Material is, connected
|
||||
with, or sponsored, endorsed, or granted official status by,
|
||||
the Licensor or others designated to receive attribution as
|
||||
provided in Section 3(a)(1)(A)(i).
|
||||
|
||||
b. Other rights.
|
||||
|
||||
1. Moral rights, such as the right of integrity, are not
|
||||
licensed under this Public License, nor are publicity,
|
||||
privacy, and/or other similar personality rights; however, to
|
||||
the extent possible, the Licensor waives and/or agrees not to
|
||||
assert any such rights held by the Licensor to the limited
|
||||
extent necessary to allow You to exercise the Licensed
|
||||
Rights, but not otherwise.
|
||||
|
||||
2. Patent and trademark rights are not licensed under this
|
||||
Public License.
|
||||
|
||||
3. To the extent possible, the Licensor waives any right to
|
||||
collect royalties from You for the exercise of the Licensed
|
||||
Rights, whether directly or through a collecting society
|
||||
under any voluntary or waivable statutory or compulsory
|
||||
licensing scheme. In all other cases the Licensor expressly
|
||||
reserves any right to collect such royalties.
|
||||
|
||||
|
||||
Section 3 -- License Conditions.
|
||||
|
||||
Your exercise of the Licensed Rights is expressly made subject to the
|
||||
following conditions.
|
||||
|
||||
a. Attribution.
|
||||
|
||||
1. If You Share the Licensed Material (including in modified
|
||||
form), You must:
|
||||
|
||||
a. retain the following if it is supplied by the Licensor
|
||||
with the Licensed Material:
|
||||
|
||||
i. identification of the creator(s) of the Licensed
|
||||
Material and any others designated to receive
|
||||
attribution, in any reasonable manner requested by
|
||||
the Licensor (including by pseudonym if
|
||||
designated);
|
||||
|
||||
ii. a copyright notice;
|
||||
|
||||
iii. a notice that refers to this Public License;
|
||||
|
||||
iv. a notice that refers to the disclaimer of
|
||||
warranties;
|
||||
|
||||
v. a URI or hyperlink to the Licensed Material to the
|
||||
extent reasonably practicable;
|
||||
|
||||
b. indicate if You modified the Licensed Material and
|
||||
retain an indication of any previous modifications; and
|
||||
|
||||
c. indicate the Licensed Material is licensed under this
|
||||
Public License, and include the text of, or the URI or
|
||||
hyperlink to, this Public License.
|
||||
|
||||
2. You may satisfy the conditions in Section 3(a)(1) in any
|
||||
reasonable manner based on the medium, means, and context in
|
||||
which You Share the Licensed Material. For example, it may be
|
||||
reasonable to satisfy the conditions by providing a URI or
|
||||
hyperlink to a resource that includes the required
|
||||
information.
|
||||
|
||||
3. If requested by the Licensor, You must remove any of the
|
||||
information required by Section 3(a)(1)(A) to the extent
|
||||
reasonably practicable.
|
||||
|
||||
b. ShareAlike.
|
||||
|
||||
In addition to the conditions in Section 3(a), if You Share
|
||||
Adapted Material You produce, the following conditions also apply.
|
||||
|
||||
1. The Adapter's License You apply must be a Creative Commons
|
||||
license with the same License Elements, this version or
|
||||
later, or a BY-SA Compatible License.
|
||||
|
||||
2. You must include the text of, or the URI or hyperlink to, the
|
||||
Adapter's License You apply. You may satisfy this condition
|
||||
in any reasonable manner based on the medium, means, and
|
||||
context in which You Share Adapted Material.
|
||||
|
||||
3. You may not offer or impose any additional or different terms
|
||||
or conditions on, or apply any Effective Technological
|
||||
Measures to, Adapted Material that restrict exercise of the
|
||||
rights granted under the Adapter's License You apply.
|
||||
|
||||
|
||||
Section 4 -- Sui Generis Database Rights.
|
||||
|
||||
Where the Licensed Rights include Sui Generis Database Rights that
|
||||
apply to Your use of the Licensed Material:
|
||||
|
||||
a. for the avoidance of doubt, Section 2(a)(1) grants You the right
|
||||
to extract, reuse, reproduce, and Share all or a substantial
|
||||
portion of the contents of the database;
|
||||
|
||||
b. if You include all or a substantial portion of the database
|
||||
contents in a database in which You have Sui Generis Database
|
||||
Rights, then the database in which You have Sui Generis Database
|
||||
Rights (but not its individual contents) is Adapted Material,
|
||||
|
||||
including for purposes of Section 3(b); and
|
||||
c. You must comply with the conditions in Section 3(a) if You Share
|
||||
all or a substantial portion of the contents of the database.
|
||||
|
||||
For the avoidance of doubt, this Section 4 supplements and does not
|
||||
replace Your obligations under this Public License where the Licensed
|
||||
Rights include other Copyright and Similar Rights.
|
||||
|
||||
|
||||
Section 5 -- Disclaimer of Warranties and Limitation of Liability.
|
||||
|
||||
a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE
|
||||
EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS
|
||||
AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF
|
||||
ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS,
|
||||
IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION,
|
||||
WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS,
|
||||
ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT
|
||||
KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT
|
||||
ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU.
|
||||
|
||||
b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE
|
||||
TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION,
|
||||
NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT,
|
||||
INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES,
|
||||
COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR
|
||||
USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN
|
||||
ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR
|
||||
DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR
|
||||
IN PART, THIS LIMITATION MAY NOT APPLY TO YOU.
|
||||
|
||||
c. The disclaimer of warranties and limitation of liability provided
|
||||
above shall be interpreted in a manner that, to the extent
|
||||
possible, most closely approximates an absolute disclaimer and
|
||||
waiver of all liability.
|
||||
|
||||
|
||||
Section 6 -- Term and Termination.
|
||||
|
||||
a. This Public License applies for the term of the Copyright and
|
||||
Similar Rights licensed here. However, if You fail to comply with
|
||||
this Public License, then Your rights under this Public License
|
||||
terminate automatically.
|
||||
|
||||
b. Where Your right to use the Licensed Material has terminated under
|
||||
Section 6(a), it reinstates:
|
||||
|
||||
1. automatically as of the date the violation is cured, provided
|
||||
it is cured within 30 days of Your discovery of the
|
||||
violation; or
|
||||
|
||||
2. upon express reinstatement by the Licensor.
|
||||
|
||||
For the avoidance of doubt, this Section 6(b) does not affect any
|
||||
right the Licensor may have to seek remedies for Your violations
|
||||
of this Public License.
|
||||
|
||||
c. For the avoidance of doubt, the Licensor may also offer the
|
||||
Licensed Material under separate terms or conditions or stop
|
||||
distributing the Licensed Material at any time; however, doing so
|
||||
will not terminate this Public License.
|
||||
|
||||
d. Sections 1, 5, 6, 7, and 8 survive termination of this Public
|
||||
License.
|
||||
|
||||
|
||||
Section 7 -- Other Terms and Conditions.
|
||||
|
||||
a. The Licensor shall not be bound by any additional or different
|
||||
terms or conditions communicated by You unless expressly agreed.
|
||||
|
||||
b. Any arrangements, understandings, or agreements regarding the
|
||||
Licensed Material not stated herein are separate from and
|
||||
independent of the terms and conditions of this Public License.
|
||||
|
||||
|
||||
Section 8 -- Interpretation.
|
||||
|
||||
a. For the avoidance of doubt, this Public License does not, and
|
||||
shall not be interpreted to, reduce, limit, restrict, or impose
|
||||
conditions on any use of the Licensed Material that could lawfully
|
||||
be made without permission under this Public License.
|
||||
|
||||
b. To the extent possible, if any provision of this Public License is
|
||||
deemed unenforceable, it shall be automatically reformed to the
|
||||
minimum extent necessary to make it enforceable. If the provision
|
||||
cannot be reformed, it shall be severed from this Public License
|
||||
without affecting the enforceability of the remaining terms and
|
||||
conditions.
|
||||
|
||||
c. No term or condition of this Public License will be waived and no
|
||||
failure to comply consented to unless expressly agreed to by the
|
||||
Licensor.
|
||||
|
||||
d. Nothing in this Public License constitutes or may be interpreted
|
||||
as a limitation upon, or waiver of, any privileges and immunities
|
||||
that apply to the Licensor or You, including from the legal
|
||||
processes of any jurisdiction or authority.
|
||||
|
||||
|
||||
=======================================================================
|
||||
|
||||
Creative Commons is not a party to its public
|
||||
licenses. Notwithstanding, Creative Commons may elect to apply one of
|
||||
its public licenses to material it publishes and in those instances
|
||||
will be considered the “Licensor.” The text of the Creative Commons
|
||||
public licenses is dedicated to the public domain under the CC0 Public
|
||||
Domain Dedication. Except for the limited purpose of indicating that
|
||||
material is shared under a Creative Commons public license or as
|
||||
otherwise permitted by the Creative Commons policies published at
|
||||
creativecommons.org/policies, Creative Commons does not authorize the
|
||||
use of the trademark "Creative Commons" or any other trademark or logo
|
||||
of Creative Commons without its prior written consent including,
|
||||
without limitation, in connection with any unauthorized modifications
|
||||
to any of its public licenses or any other arrangements,
|
||||
understandings, or agreements concerning use of licensed material. For
|
||||
the avoidance of doubt, this paragraph does not form part of the
|
||||
public licenses.
|
||||
|
||||
Creative Commons may be contacted at creativecommons.org.
|
||||
|
||||
@@ -0,0 +1,244 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Build the embedded knowledge pack from the official sources.
|
||||
|
||||
The output is committed so the agent binary does not need network access at
|
||||
runtime. Re-run this script to refresh the pack; it records the source URL,
|
||||
license, retrieval date and source digest in knowledge/data/sources.json.
|
||||
|
||||
Usage:
|
||||
python3 scripts/knowledge/build.py
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import csv
|
||||
import hashlib
|
||||
import io
|
||||
import json
|
||||
import sys
|
||||
import urllib.request
|
||||
import zipfile
|
||||
from datetime import date
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
DATA = ROOT / "knowledge" / "data"
|
||||
LICENSES = ROOT / "knowledge" / "licenses"
|
||||
|
||||
ATTACK_URL = "https://raw.githubusercontent.com/mitre-attack/attack-stix-data/master/enterprise-attack/enterprise-attack.json"
|
||||
ATTACK_LICENSE_URL = "https://raw.githubusercontent.com/mitre-attack/attack-stix-data/master/LICENSE.txt"
|
||||
WSTG_URL = "https://raw.githubusercontent.com/OWASP/wstg/master/checklists/checklist.json"
|
||||
WSTG_LICENSE_URL = "https://raw.githubusercontent.com/OWASP/wstg/master/LICENSE"
|
||||
CWE_URL = "https://cwe.mitre.org/data/csv/1000.csv"
|
||||
CWE_TERMS_URL = "https://cwe.mitre.org/about/termsofuse.html"
|
||||
|
||||
MAX_ATTACK_DESCRIPTION = 400
|
||||
MAX_WSTG_DESCRIPTION = 400
|
||||
MAX_CWE_DESCRIPTION = 300
|
||||
|
||||
CWE_TERMS_TEXT = """CWE™ is free to use by any organization or individual for any research,
|
||||
development, and/or commercial purposes, per these CWE Terms of Use.
|
||||
Accordingly, The MITRE Corporation hereby grants you a non-exclusive,
|
||||
royalty-free license to use CWE for research, development, and commercial
|
||||
purposes. Any copy you make for such purposes is authorized on the condition
|
||||
that you reproduce MITRE's copyright designation and this license in any such
|
||||
copy. CWE is a trademark of The MITRE Corporation.
|
||||
|
||||
Copyright © 2006-2026, The MITRE Corporation.
|
||||
|
||||
Full terms: https://cwe.mitre.org/about/termsofuse.html
|
||||
"""
|
||||
|
||||
|
||||
def fetch(url: str) -> bytes:
|
||||
req = urllib.request.Request(url, headers={"User-Agent": "artex-knowledge-build/1"})
|
||||
with urllib.request.urlopen(req, timeout=120) as resp:
|
||||
return resp.read()
|
||||
|
||||
|
||||
def digest(raw: bytes) -> str:
|
||||
return hashlib.sha256(raw).hexdigest()
|
||||
|
||||
|
||||
def clip(text: str, limit: int) -> tuple[str, bool]:
|
||||
text = " ".join((text or "").split())
|
||||
if len(text) <= limit:
|
||||
return text, False
|
||||
return text[: limit - 1].rstrip() + "…", True
|
||||
|
||||
|
||||
def attack_entries(raw: bytes) -> list[dict]:
|
||||
bundle = json.loads(raw)
|
||||
out: list[dict] = []
|
||||
for obj in bundle.get("objects", []):
|
||||
if obj.get("type") != "attack-pattern":
|
||||
continue
|
||||
if obj.get("revoked") or obj.get("x_mitre_deprecated"):
|
||||
continue
|
||||
ref = next(
|
||||
(r for r in obj.get("external_references", []) if r.get("source_name") == "mitre-attack"),
|
||||
None,
|
||||
)
|
||||
if not ref or not ref.get("external_id"):
|
||||
continue
|
||||
description, truncated = clip(obj.get("description", ""), MAX_ATTACK_DESCRIPTION)
|
||||
tactics = sorted(
|
||||
{
|
||||
p.get("phase_name", "")
|
||||
for p in obj.get("kill_chain_phases", [])
|
||||
if p.get("kill_chain_name") == "mitre-attack" and p.get("phase_name")
|
||||
}
|
||||
)
|
||||
out.append(
|
||||
{
|
||||
"id": ref["external_id"],
|
||||
"name": obj.get("name", ""),
|
||||
"category": tactics,
|
||||
"description": description,
|
||||
"truncated": truncated,
|
||||
"url": ref.get("url") or f"https://attack.mitre.org/techniques/{ref['external_id'].replace('.', '/')}/",
|
||||
}
|
||||
)
|
||||
return sorted(out, key=lambda e: e["id"])
|
||||
|
||||
|
||||
def wstg_entries(raw: bytes) -> list[dict]:
|
||||
checklist = json.loads(raw)
|
||||
out: list[dict] = []
|
||||
for category, body in checklist.get("categories", {}).items():
|
||||
for test in body.get("tests", []):
|
||||
description, truncated = clip(" ".join(test.get("objectives", [])), MAX_WSTG_DESCRIPTION)
|
||||
out.append(
|
||||
{
|
||||
"id": test.get("id", ""),
|
||||
"name": test.get("name", ""),
|
||||
"category": [category],
|
||||
"description": description,
|
||||
"truncated": truncated,
|
||||
"url": test.get("reference", ""),
|
||||
}
|
||||
)
|
||||
return sorted(out, key=lambda e: e["id"])
|
||||
|
||||
|
||||
def cwe_entries(raw_zip: bytes) -> list[dict]:
|
||||
out: list[dict] = []
|
||||
with zipfile.ZipFile(io.BytesIO(raw_zip)) as zf:
|
||||
name = next((n for n in zf.namelist() if n.endswith(".csv")), None)
|
||||
if not name:
|
||||
raise SystemExit("CWE archive has no CSV")
|
||||
text = io.TextIOWrapper(zf.open(name), encoding="utf-8", errors="replace", newline="")
|
||||
for row in csv.DictReader(text):
|
||||
cid = (row.get("CWE-ID") or "").strip()
|
||||
if not cid.isdigit():
|
||||
continue
|
||||
description, truncated = clip(row.get("Description", ""), MAX_CWE_DESCRIPTION)
|
||||
out.append(
|
||||
{
|
||||
"id": f"CWE-{cid}",
|
||||
"name": (row.get("Name") or "").strip(),
|
||||
"category": [(row.get("Weakness Abstraction") or "").strip()],
|
||||
"status": (row.get("Status") or "").strip(),
|
||||
"description": description,
|
||||
"truncated": truncated,
|
||||
"url": f"https://cwe.mitre.org/data/definitions/{cid}.html",
|
||||
}
|
||||
)
|
||||
return sorted(out, key=lambda e: int(e["id"].split("-", 1)[1]))
|
||||
|
||||
|
||||
def write_json(path: Path, value: object) -> None:
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
path.write_text(json.dumps(value, ensure_ascii=False, indent=2) + "\n", encoding="utf-8", newline="\n")
|
||||
|
||||
|
||||
def main() -> int:
|
||||
retrieved = date.today().isoformat()
|
||||
|
||||
attack_raw = fetch(ATTACK_URL)
|
||||
wstg_raw = fetch(WSTG_URL)
|
||||
cwe_raw = fetch(CWE_URL)
|
||||
|
||||
attack = attack_entries(attack_raw)
|
||||
wstg = wstg_entries(wstg_raw)
|
||||
cwe = cwe_entries(cwe_raw)
|
||||
if not attack or not wstg or not cwe:
|
||||
raise SystemExit("one of the sources produced no entries")
|
||||
|
||||
packs = [
|
||||
(
|
||||
"attack",
|
||||
"MITRE ATT&CK Enterprise",
|
||||
"MITRE ATT&CK Terms of Use",
|
||||
ATTACK_URL,
|
||||
ATTACK_LICENSE_URL,
|
||||
digest(attack_raw),
|
||||
attack,
|
||||
),
|
||||
(
|
||||
"wstg",
|
||||
"OWASP Web Security Testing Guide",
|
||||
"CC-BY-SA-4.0",
|
||||
WSTG_URL,
|
||||
WSTG_LICENSE_URL,
|
||||
digest(wstg_raw),
|
||||
wstg,
|
||||
),
|
||||
(
|
||||
"cwe",
|
||||
"MITRE Common Weakness Enumeration",
|
||||
"MITRE CWE Terms of Use",
|
||||
CWE_URL,
|
||||
CWE_TERMS_URL,
|
||||
digest(cwe_raw),
|
||||
cwe,
|
||||
),
|
||||
]
|
||||
|
||||
manifest = {"generated_at": retrieved, "sources": []}
|
||||
for source, title, license_name, url, license_url, sha256, entries in packs:
|
||||
write_json(
|
||||
DATA / f"{source}.json",
|
||||
{
|
||||
"source": source,
|
||||
"title": title,
|
||||
"license": license_name,
|
||||
"license_url": license_url,
|
||||
"source_url": url,
|
||||
"retrieved_at": retrieved,
|
||||
"sha256": sha256,
|
||||
"entries": entries,
|
||||
},
|
||||
)
|
||||
manifest["sources"].append(
|
||||
{
|
||||
"source": source,
|
||||
"title": title,
|
||||
"license": license_name,
|
||||
"license_url": license_url,
|
||||
"source_url": url,
|
||||
"retrieved_at": retrieved,
|
||||
"sha256": sha256,
|
||||
"entries": len(entries),
|
||||
"data_file": f"data/{source}.json",
|
||||
}
|
||||
)
|
||||
|
||||
write_json(DATA / "sources.json", manifest)
|
||||
|
||||
LICENSES.mkdir(parents=True, exist_ok=True)
|
||||
(LICENSES / "ATTACK-LICENSE.txt").write_bytes(fetch(ATTACK_LICENSE_URL).replace(b"\r\n", b"\n"))
|
||||
(LICENSES / "WSTG-LICENSE.txt").write_bytes(fetch(WSTG_LICENSE_URL).replace(b"\r\n", b"\n"))
|
||||
(LICENSES / "CWE-TERMS.html").write_bytes(fetch(CWE_TERMS_URL).replace(b"\r\n", b"\n"))
|
||||
(LICENSES / "CWE-TERMS.txt").write_text(CWE_TERMS_TEXT, encoding="utf-8", newline="\n")
|
||||
(LICENSES / "CWE-TERMS.url").write_text(CWE_TERMS_URL + "\n", encoding="utf-8", newline="\n")
|
||||
|
||||
print(f"attack: {len(attack)} entries")
|
||||
print(f"wstg: {len(wstg)} entries")
|
||||
print(f"cwe: {len(cwe)} entries")
|
||||
print(f"wrote {DATA} and {LICENSES}")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
Reference in New Issue
Block a user