Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,28 @@ def _product_signature(entry: dict[str, Any]) -> tuple[str, str]:
return (_package_identity(entry), str(entry.get("product") or ""))


#: The product Vulnogram writes into ``affected[]`` when it allocates a CVE ID.
ALLOCATION_PLACEHOLDER_PRODUCT = "[VENDOR] [PRODUCT]"
Comment thread
Kaap10 marked this conversation as resolved.
Resolved

#: The ``CNA_private.state`` values of a record nobody has submitted for review yet.
#: Only in these states is the allocation placeholder exempt from the product guard.
PLACEHOLDER_EXEMPT_STATES = frozenset({"RESERVED", "DRAFT"})


def _is_placeholder_entry(entry: Any) -> bool:
"""Return ``True`` for an entry with the allocation placeholder product and no package."""
return (
isinstance(entry, dict)
and entry.get("product") == ALLOCATION_PLACEHOLDER_PRODUCT
and not _package_identity(entry)
)


def _diff_affected_products(
current: list[dict[str, Any]],
new: list[dict[str, Any]],
*,
current_state: str | None = None,
) -> list[str]:
"""Return a list of human-readable diffs for product/packageName
changes between the current and new affected[] arrays.
Expand All @@ -191,16 +210,22 @@ def _diff_affected_products(
is read from ``packageURL`` or ``packageName``, whichever the entry
carries, so the two identifier shapes do not read as a rename.
Otherwise returns one line per dropped, added, or renamed signature so
the caller can decide whether to refuse or warn.
the caller can decide whether to refuse or warn. Allocation placeholders
in ``current`` are not authored content and are left out (#1736), but
only while ``current_state`` is one of :data:`PLACEHOLDER_EXEMPT_STATES`;
once the record has moved on, the guard compares them like any product.
"""
current_sigs = {_product_signature(entry) for entry in current if isinstance(entry, dict)}
skip_placeholders = current_state in PLACEHOLDER_EXEMPT_STATES
current_sigs = {
_product_signature(entry)
for entry in current
if isinstance(entry, dict) and not (skip_placeholders and _is_placeholder_entry(entry))
}
new_sigs = {_product_signature(entry) for entry in new if isinstance(entry, dict)}
if current_sigs == new_sigs:
return []
# First-time population (e.g. a freshly-allocated RESERVED record with an
# empty ``affected[]``) is not a product *change* — there is no prior
# signature to be renamed away from. Treat it as a non-diff so the guard
# does not force --allow-product-change for the normal first push.
# An empty ``affected[]`` is first-time population, not a product
# *change* — there is no prior signature to be renamed away from.
if not current_sigs:
return []
diffs: list[str] = []
Expand Down Expand Up @@ -254,7 +279,9 @@ def apply_merge_mode_guards(
current record and the new emission, raise
:class:`MergeModeRefused` with a diff so the caller can decide
whether the change is intentional (e.g. broadening the scope
to add a new package) or a regression.
to add a new package) or a regression. Replacing Vulnogram's
allocation placeholder is exempt while the record is still
``RESERVED`` or ``DRAFT``.

With ``forbid_promotion_to_public`` (the vetted-ops path always sets
it), a push that would move the record to ``PUBLIC`` from any other
Expand Down Expand Up @@ -363,6 +390,7 @@ def apply_merge_mode_guards(
diffs = _diff_affected_products(
current=_current_affected(current_doc),
new=_new_affected(merged),
current_state=current_state,
)
if diffs and not allow_product_change:
raise MergeModeRefused(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@
**Merge mode (default on)** — before the POST, the script fetches
the record's current state and applies three safety nets against
the document about to be pushed: state-downgrade refusal,
references-by-URL merge, product/package-change refusal. See
references-by-URL merge, product/package-change refusal
(the first push after allocation, while the record is still
``RESERVED`` or ``DRAFT``, is exempt). See
:mod:`vulnogram_api.merge_mode` for the full rules, and the
``--allow-state-downgrade`` / ``--replace-references`` /
``--allow-product-change`` / ``--full-replace`` flags below for the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,7 @@ When the state fetch fails, pass `fetched_state: "unknown"`.
Any other outcome (an interrupted run) may or may not have saved: push again, which the idempotence note below makes safe.

For Vulnogram, the push merges into the live record and refuses to rename an affected product or package.
The first push after allocation, which replaces Vulnogram's placeholder product while the record is still `RESERVED` or `DRAFT`, needs no override.
Two explicit overrides exist; use them only after confirming with the user:

- `--replace-references` — replace `references[]` instead of keeping existing URLs.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,28 @@ def _product_signature(entry: dict[str, Any]) -> tuple[str, str]:
return (_package_identity(entry), str(entry.get("product") or ""))


#: The product Vulnogram writes into ``affected[]`` when it allocates a CVE ID.
ALLOCATION_PLACEHOLDER_PRODUCT = "[VENDOR] [PRODUCT]"

#: The ``CNA_private.state`` values of a record nobody has submitted for review yet.
#: Only in these states is the allocation placeholder exempt from the product guard.
PLACEHOLDER_EXEMPT_STATES = frozenset({"RESERVED", "DRAFT"})


def _is_placeholder_entry(entry: Any) -> bool:
"""Return ``True`` for an entry with the allocation placeholder product and no package."""
return (
isinstance(entry, dict)
and entry.get("product") == ALLOCATION_PLACEHOLDER_PRODUCT
and not _package_identity(entry)
)


def _diff_affected_products(
current: list[dict[str, Any]],
new: list[dict[str, Any]],
*,
current_state: str | None = None,
) -> list[str]:
"""Return a list of human-readable diffs for product/packageName
changes between the current and new affected[] arrays.
Expand All @@ -191,16 +210,22 @@ def _diff_affected_products(
is read from ``packageURL`` or ``packageName``, whichever the entry
carries, so the two identifier shapes do not read as a rename.
Otherwise returns one line per dropped, added, or renamed signature so
the caller can decide whether to refuse or warn.
the caller can decide whether to refuse or warn. Allocation placeholders
in ``current`` are not authored content and are left out (#1736), but
only while ``current_state`` is one of :data:`PLACEHOLDER_EXEMPT_STATES`;
once the record has moved on, the guard compares them like any product.
"""
current_sigs = {_product_signature(entry) for entry in current if isinstance(entry, dict)}
skip_placeholders = current_state in PLACEHOLDER_EXEMPT_STATES
current_sigs = {
_product_signature(entry)
for entry in current
if isinstance(entry, dict) and not (skip_placeholders and _is_placeholder_entry(entry))
}
new_sigs = {_product_signature(entry) for entry in new if isinstance(entry, dict)}
if current_sigs == new_sigs:
return []
# First-time population (e.g. a freshly-allocated RESERVED record with an
# empty ``affected[]``) is not a product *change* — there is no prior
# signature to be renamed away from. Treat it as a non-diff so the guard
# does not force --allow-product-change for the normal first push.
# An empty ``affected[]`` is first-time population, not a product
# *change* — there is no prior signature to be renamed away from.
if not current_sigs:
return []
diffs: list[str] = []
Expand Down Expand Up @@ -254,7 +279,9 @@ def apply_merge_mode_guards(
current record and the new emission, raise
:class:`MergeModeRefused` with a diff so the caller can decide
whether the change is intentional (e.g. broadening the scope
to add a new package) or a regression.
to add a new package) or a regression. Replacing Vulnogram's
allocation placeholder is exempt while the record is still
``RESERVED`` or ``DRAFT``.

With ``forbid_promotion_to_public`` (the vetted-ops path always sets
it), a push that would move the record to ``PUBLIC`` from any other
Expand Down Expand Up @@ -363,6 +390,7 @@ def apply_merge_mode_guards(
diffs = _diff_affected_products(
current=_current_affected(current_doc),
new=_new_affected(merged),
current_state=current_state,
)
if diffs and not allow_product_change:
raise MergeModeRefused(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@
**Merge mode (default on)** — before the POST, the script fetches
the record's current state and applies three safety nets against
the document about to be pushed: state-downgrade refusal,
references-by-URL merge, product/package-change refusal. See
references-by-URL merge, product/package-change refusal
(the first push after allocation, while the record is still
``RESERVED`` or ``DRAFT``, is exempt). See
:mod:`vulnogram_api.merge_mode` for the full rules, and the
``--allow-state-downgrade`` / ``--replace-references`` /
``--allow-product-change`` / ``--full-replace`` flags below for the
Expand Down
42 changes: 35 additions & 7 deletions tools/cve-tool-vulnogram/oauth-api/src/vulnogram_api/merge_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,28 @@ def _product_signature(entry: dict[str, Any]) -> tuple[str, str]:
return (_package_identity(entry), str(entry.get("product") or ""))


#: The product Vulnogram writes into ``affected[]`` when it allocates a CVE ID.
ALLOCATION_PLACEHOLDER_PRODUCT = "[VENDOR] [PRODUCT]"

#: The ``CNA_private.state`` values of a record nobody has submitted for review yet.
#: Only in these states is the allocation placeholder exempt from the product guard.
PLACEHOLDER_EXEMPT_STATES = frozenset({"RESERVED", "DRAFT"})


def _is_placeholder_entry(entry: Any) -> bool:
"""Return ``True`` for an entry with the allocation placeholder product and no package."""
return (
isinstance(entry, dict)
and entry.get("product") == ALLOCATION_PLACEHOLDER_PRODUCT
and not _package_identity(entry)
)


def _diff_affected_products(
current: list[dict[str, Any]],
new: list[dict[str, Any]],
*,
current_state: str | None = None,
) -> list[str]:
"""Return a list of human-readable diffs for product/packageName
changes between the current and new affected[] arrays.
Expand All @@ -191,16 +210,22 @@ def _diff_affected_products(
is read from ``packageURL`` or ``packageName``, whichever the entry
carries, so the two identifier shapes do not read as a rename.
Otherwise returns one line per dropped, added, or renamed signature so
the caller can decide whether to refuse or warn.
the caller can decide whether to refuse or warn. Allocation placeholders
in ``current`` are not authored content and are left out (#1736), but
only while ``current_state`` is one of :data:`PLACEHOLDER_EXEMPT_STATES`;
once the record has moved on, the guard compares them like any product.
"""
current_sigs = {_product_signature(entry) for entry in current if isinstance(entry, dict)}
skip_placeholders = current_state in PLACEHOLDER_EXEMPT_STATES
current_sigs = {
_product_signature(entry)
for entry in current
if isinstance(entry, dict) and not (skip_placeholders and _is_placeholder_entry(entry))
}
new_sigs = {_product_signature(entry) for entry in new if isinstance(entry, dict)}
if current_sigs == new_sigs:
return []
# First-time population (e.g. a freshly-allocated RESERVED record with an
# empty ``affected[]``) is not a product *change* — there is no prior
# signature to be renamed away from. Treat it as a non-diff so the guard
# does not force --allow-product-change for the normal first push.
# An empty ``affected[]`` is first-time population, not a product
# *change* — there is no prior signature to be renamed away from.
if not current_sigs:
return []
diffs: list[str] = []
Expand Down Expand Up @@ -254,7 +279,9 @@ def apply_merge_mode_guards(
current record and the new emission, raise
:class:`MergeModeRefused` with a diff so the caller can decide
whether the change is intentional (e.g. broadening the scope
to add a new package) or a regression.
to add a new package) or a regression. Replacing Vulnogram's
allocation placeholder is exempt while the record is still
``RESERVED`` or ``DRAFT``.

With ``forbid_promotion_to_public`` (the vetted-ops path always sets
it), a push that would move the record to ``PUBLIC`` from any other
Expand Down Expand Up @@ -363,6 +390,7 @@ def apply_merge_mode_guards(
diffs = _diff_affected_products(
current=_current_affected(current_doc),
new=_new_affected(merged),
current_state=current_state,
)
if diffs and not allow_product_change:
raise MergeModeRefused(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@
**Merge mode (default on)** — before the POST, the script fetches
the record's current state and applies three safety nets against
the document about to be pushed: state-downgrade refusal,
references-by-URL merge, product/package-change refusal. See
references-by-URL merge, product/package-change refusal
(the first push after allocation, while the record is still
``RESERVED`` or ``DRAFT``, is exempt). See
:mod:`vulnogram_api.merge_mode` for the full rules, and the
``--allow-state-downgrade`` / ``--replace-references`` /
``--allow-product-change`` / ``--full-replace`` flags below for the
Expand Down
80 changes: 80 additions & 0 deletions tools/cve-tool-vulnogram/oauth-api/tests/test_merge_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,86 @@ def test_first_time_population_does_not_require_allow_product_change(self):
assert merged["containers"]["cna"]["affected"][0]["packageName"] == "apache-foo"


# ---------------------------------------------------------------------------
# Allocation placeholder (issue #1736)
# ---------------------------------------------------------------------------

PLACEHOLDER = {"product": "[VENDOR] [PRODUCT]"}
REAL_ENTRY = {"packageURL": "pkg:maven/org.apache.foo/foo-core", "product": "Apache Foo"}


def _allocated(**kwargs) -> dict:
"""A record as Vulnogram leaves it right after allocation."""
kwargs.setdefault("state", "RESERVED")
kwargs.setdefault("references", [])
return _current(**kwargs)


class TestAllocationPlaceholder:
def test_first_push_replaces_the_untouched_placeholder(self):
merged = apply_merge_mode_guards(
_allocated(affected=[PLACEHOLDER]),
_new(state="DRAFT", affected=[REAL_ENTRY]),
)
assert merged["containers"]["cna"]["affected"] == [REAL_ENTRY]

def test_dropping_a_placeholder_next_to_an_authored_entry_is_allowed(self):
merged = apply_merge_mode_guards(
_allocated(affected=[PLACEHOLDER, REAL_ENTRY]),
_new(state="DRAFT", affected=[REAL_ENTRY]),
)
assert merged["containers"]["cna"]["affected"] == [REAL_ENTRY]

def test_renaming_an_authored_entry_next_to_a_placeholder_still_refuses(self):
with pytest.raises(MergeModeRefused, match="product"):
apply_merge_mode_guards(
_allocated(affected=[PLACEHOLDER, REAL_ENTRY]),
_new(state="DRAFT", affected=[{"packageName": "apache-bar", "product": "Apache Bar"}]),
)

def test_placeholder_product_with_a_package_still_refuses(self):
with pytest.raises(MergeModeRefused, match="product"):
apply_merge_mode_guards(
_allocated(affected=[{"packageName": "apache-foo", "product": "[VENDOR] [PRODUCT]"}]),
_new(state="DRAFT", affected=[REAL_ENTRY]),
)

def test_a_vendor_on_the_placeholder_does_not_matter(self):
merged = apply_merge_mode_guards(
_allocated(affected=[{"vendor": "Apache Software Foundation", **PLACEHOLDER}]),
_new(state="DRAFT", affected=[REAL_ENTRY]),
)
assert merged["containers"]["cna"]["affected"] == [REAL_ENTRY]

def test_draft_record_also_replaces_the_placeholder(self):
merged = apply_merge_mode_guards(
_allocated(state="DRAFT", affected=[PLACEHOLDER]),
_new(state="DRAFT", affected=[REAL_ENTRY]),
)
assert merged["containers"]["cna"]["affected"] == [REAL_ENTRY]

@pytest.mark.parametrize("state", ["REVIEW", "READY", "PUBLIC", None])
def test_placeholder_past_draft_still_refuses(self, state):
current = _allocated(state=state, affected=[PLACEHOLDER])
if state is None:
del current["body"]["CNA_private"]["state"]
# Keep the state (and, for PUBLIC, the advisory reference) so only the
# product guard can fire.
advisory = [{"url": "https://lists.apache.org/thread/abc", "tags": ["vendor-advisory"]}]
new = _new(state=state or "DRAFT", references=advisory, affected=[REAL_ENTRY])
with pytest.raises(MergeModeRefused, match="product"):
apply_merge_mode_guards(current, new)

def test_second_push_after_population_keeps_the_guard(self):
with pytest.raises(MergeModeRefused, match="product"):
apply_merge_mode_guards(
_allocated(affected=[REAL_ENTRY]),
_new(
state="DRAFT", affected=[{"packageName": "apache-foo-bar", "product": "Apache Foo Bar"}]
),
)


# ---------------------------------------------------------------------------
# Composition + edge cases
# ---------------------------------------------------------------------------
Expand Down
2 changes: 2 additions & 0 deletions tools/skill-evals/evals/security-issue-sync/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ Columns and rules: [Recording runs](../../README.md#recording-runs).

| Date | Ref | Model | Runs | Result | Notes |
|---|---|---|---|---|---|
| 2026-11-22 | `93050ec5` (fix/1736-allocation-placeholder) | (unrecorded, `claude -p`) | 1 | pass | re-run after review fixes on #2194 |
| 2026-11-18 | `57480dcf` (fix/1736-allocation-placeholder) | `opus[1m]` | 1 | pass | |
| 2026-11-18 | `add4ee52` (feat/security-skills-vetted-cve-ops) | `opus[1m]` | 2 | pass | |
| 2026-11-18 | `9e979ff3` (feat/security-skills-vetted-cve-ops) | `opus[1m]` | 1 | pass | |
| 2026-11-13 | `c22d5769` (feat/cve-tool-interface) | `claude-sonnet-5-5` | 10 | `step-2b-proposed-changes/case-2-milestone-missing-create` failed 1 of 2; `step-2b-proposed-changes/case-5-pre-announce-distributors` failed 2 of 2; `step-2b-proposed-changes/case-6-reporter-unresponsive` errored 1 of 2 | cross-model check for #1800; cross-model check for #1800 (re-run of infra failures) |
Loading