- Python 100%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| .github/workflows | ||
| examples | ||
| src/openvulnerability | ||
| tests | ||
| tools | ||
| .gitattributes | ||
| .gitignore | ||
| CONTRIBUTING.md | ||
| LICENSE | ||
| MANIFEST.in | ||
| pyproject.toml | ||
| README.md | ||
| SISO-NOTICE.txt | ||
OpenVulnerability
OpenVulnerability classifies seven-field DIS entity types using SISO-REF-010 v37 and resolves fictional effects.
Install
Use Python 3.11 or later. Install a release wheel with python -m pip install --no-index ./dist/openvulnerability-0.1.0-py3-none-any.whl, or run python -m pip install . from a checkout. The installed library uses only the standard library. The wheel includes the original XML and a ready-to-query read-only SQLite catalog.
Identify an entity
from openvulnerability import Catalog, EntityType
with Catalog.bundled() as catalog:
result = catalog.lookup("1.1.225.1.0.0.0")
print(result.code, result.category_label, result.matched_level)
# 1.1.225.1.0.0.0 Tank category
categories = dict(catalog.children("1.1", level="category"))
assert categories[1] == "Tank"
result = catalog.lookup(EntityType(1, 1, 13, 7, 1, 255, 0))
print(result.subcategory_label, result.matched_level)
# RMMV HX40M - 4x4 subcategory
Fields are kind, domain, country, category, subcategory, specific, and extra. Country occupies 16 bits. Each other field occupies 8 bits. Zero is a value at every position. The immutable result keeps the numeric code and a label per field. A missing label is None.
Lookup walks the country-specific branch and consults shared tables whose applicability covers the prefix. An unknown subtype of land platform category 1 can still identify a Tank. A match through kind 3 and domain 1 identifies a land life form. Country names are independent metadata. Country counts as a matched hierarchy level when the catalog contains that branch. matched_level is None when the hierarchy provides no match.
children(prefix) returns sorted numeric value and label pairs for the next field. Use an empty string for kinds. Use children("1.1", level="category") for shared categories across countries or children("1.1.13") to include Australian entries.
Resolve an effect with bundled defaults
Run python examples/antiTank.py to classify the imported entities and resolve the bundled generic and specific DIS rules.
Rules use seven-field DIS patterns. Each numeric field matches that exact value. * matches any value in exactly one field. The bundled generic anti-armor-versus-tank rule uses 2.2.*.*.*.*.* and 1.1.*.1.*.*.*. A more specific rule for the Spike-LR and Leopard 2 has all fourteen fields fixed and wins when both rules apply.
from openvulnerability import Catalog, EffectModel
with Catalog.bundled() as catalog:
leopard = catalog.lookup("1.1.78.1.2.0.0")
spike_lr = catalog.lookup("2.2.105.1.3.2.0")
model = EffectModel.bundled()
hit = model.resolve(effect=spike_lr.code, target=leopard.code, distance_m=2)
print(hit.damage_fraction, hit.rule_id) # 0.5 leopard-spike
resolve() accepts only concrete EntityType values. Parse a seven-field identifier with EntityType.parse() when the caller does not obtain it through Catalog. The rule with the most fixed fields across the effect and target pattern wins. Explicit priority resolves a tie in fixed-field count. An out-of-range query that has one matching rule returns matched=False, damage_fraction=0.0, and that rule ID.
Customize vulnerability with a JSON overlay
An overlay is a JSON object with a rules array. Every effect and target is a seven-field DIS pattern. Each * matches any value in exactly one field, including zero. For example, 2.2.*.*.*.*.* matches every anti-armor munition and 1.1.*.1.*.*.* matches every land tank. A numeric field matches that exact value. For example, save this as toy.json:
{
"rules": [
{
"id": "balloon.pop",
"effect": "8.0.0.1.0.0.0",
"target": "4.0.0.1.0.0.0",
"min_m": 0,
"max_m": 3,
"damage_fraction": 1.0
}
]
}
from openvulnerability import EffectModel, EntityType
model = EffectModel.bundled().with_overlay("toy.json")
hit = model.resolve(
effect=EntityType.parse("8.0.0.1.0.0.0"),
target=EntityType.parse("4.0.0.1.0.0.0"),
distance_m=2,
)
print(hit.damage_fraction, hit.rule_id) # 1.0 balloon.pop
Run python examples/balloons.py to try the same rule on two toy balloons. Each simulator entity has its own identity, but both are assigned the same concrete category code for this scenario.
Each rule specifies effect and target patterns plus a distance interval in meters. Supply min_m and either max_m or "open_ended": true. When matching rules overlap, the pattern with the most fixed fields wins. The highest integer priority resolves equal specificity. An unresolved tie raises a load-time error naming both rules. To replace a rule, supply its existing id, "replace": true, and the complete new definition. An optional version identifies the resulting rule set.
See contributor instructions for regeneration, parser evaluation, and release checks. Project code uses the MIT license. SISO data has its own redistribution notice. Reprinted with permission from SISO Inc.