feat(github): add safe credential intake readiness
This commit is contained in:
@@ -55,6 +55,17 @@ def test_load_github_target_private_backup_evidence_gate_from_committed_snapshot
|
||||
assert snapshot["summary"]["github_missing_target_refs_sync_ready_count"] == 0
|
||||
assert snapshot["summary"]["private_backup_verified_count"] == 4
|
||||
assert snapshot["summary"]["private_visibility_verified_count"] == 4
|
||||
assert snapshot["summary"]["safe_credential_required_count"] == 9
|
||||
assert snapshot["summary"]["safe_credential_accepted_evidence_count"] == 0
|
||||
assert snapshot["summary"]["safe_credential_evidence_intake_ready"] is True
|
||||
assert (
|
||||
snapshot["summary"]["safe_credential_required_redacted_evidence_ref_count"] == 9
|
||||
)
|
||||
assert snapshot["summary"]["safe_credential_evidence_ref_rule_count"] == 5
|
||||
assert snapshot["summary"]["safe_credential_redaction_example_count"] == 5
|
||||
assert snapshot["summary"]["safe_credential_forbidden_payload_count"] == 15
|
||||
assert snapshot["summary"]["safe_credential_quarantine_lane_count"] == 1
|
||||
assert snapshot["summary"]["safe_credential_raw_payload_storage_allowed"] is False
|
||||
assert snapshot["summary"]["owner_response_request_ready"] is True
|
||||
assert snapshot["summary"]["owner_response_required_response_item_count"] == 9
|
||||
assert snapshot["summary"]["owner_response_requested_template_count"] == 9
|
||||
@@ -97,6 +108,39 @@ def test_load_github_target_private_backup_evidence_gate_from_committed_snapshot
|
||||
assert "private_clone_url_credential" in intake["forbidden_payloads"]
|
||||
assert "read_only_markdown_response" in intake["allowed_submission_modes"]
|
||||
assert "create_github_repo" in intake["still_forbidden"]
|
||||
safe_credential_intake = snapshot["safe_credential_evidence_intake_readiness"]
|
||||
assert (
|
||||
safe_credential_intake["status"]
|
||||
== "ready_to_collect_redacted_evidence_refs_not_credentials"
|
||||
)
|
||||
assert safe_credential_intake["intake_ready"] is True
|
||||
assert safe_credential_intake["required_target_count"] == 9
|
||||
assert safe_credential_intake["accepted_evidence_count"] == 0
|
||||
assert safe_credential_intake["required_redacted_evidence_ref_count"] == 9
|
||||
assert safe_credential_intake["evidence_ref_rule_count"] == 5
|
||||
assert safe_credential_intake["redaction_example_count"] == 5
|
||||
assert safe_credential_intake["forbidden_payload_count"] == 15
|
||||
assert safe_credential_intake["quarantine_lane_count"] == 1
|
||||
assert "quarantine_sensitive_payload" in safe_credential_intake["quarantine_lanes"]
|
||||
assert safe_credential_intake["stored_raw_payload_allowed"] is False
|
||||
assert safe_credential_intake["secret_value_collection_allowed"] is False
|
||||
assert safe_credential_intake["private_clone_url_collection_allowed"] is False
|
||||
assert safe_credential_intake["credential_value_collection_allowed"] is False
|
||||
assert safe_credential_intake["execution_authorized"] is False
|
||||
assert safe_credential_intake["not_approval"] is True
|
||||
assert (
|
||||
"private_clone_url_credential" in safe_credential_intake["forbidden_payloads"]
|
||||
)
|
||||
assert "repo_archive" in safe_credential_intake["forbidden_payloads"]
|
||||
assert "git_object_pack" in safe_credential_intake["forbidden_payloads"]
|
||||
assert (
|
||||
"redacted_metadata_pointer"
|
||||
in safe_credential_intake["allowed_evidence_ref_types"]
|
||||
)
|
||||
first_redaction_example = safe_credential_intake["redaction_examples"][0]
|
||||
assert first_redaction_example["example_id"] == "redaction-github-target-doc-ref"
|
||||
assert first_redaction_example["stored_raw_payload_allowed"] is False
|
||||
assert first_redaction_example["execution_authorized"] is False
|
||||
|
||||
targets = {target["github_repo"]: target for target in snapshot["targets"]}
|
||||
assert targets["owenhytsai/awoooi"]["visibility_evidence_status"] == (
|
||||
@@ -112,6 +156,28 @@ def test_load_github_target_private_backup_evidence_gate_from_committed_snapshot
|
||||
targets["owenhytsai/awoooi"]["owner_response_submission_status"]
|
||||
== "waiting_owner_response"
|
||||
)
|
||||
assert (
|
||||
targets["owenhytsai/awoooi"]["safe_credential_evidence_submission_status"]
|
||||
== "waiting_redacted_evidence_ref"
|
||||
)
|
||||
assert (
|
||||
"redacted_metadata_pointer"
|
||||
in targets["owenhytsai/awoooi"]["safe_credential_allowed_evidence_ref_types"]
|
||||
)
|
||||
assert (
|
||||
targets["owenhytsai/awoooi"]["safe_credential_raw_payload_storage_allowed"]
|
||||
is False
|
||||
)
|
||||
assert (
|
||||
targets["owenhytsai/awoooi"][
|
||||
"safe_credential_private_clone_url_collection_allowed"
|
||||
]
|
||||
is False
|
||||
)
|
||||
assert (
|
||||
targets["owenhytsai/awoooi"]["safe_credential_secret_value_collection_allowed"]
|
||||
is False
|
||||
)
|
||||
assert targets["owenhytsai/awoooi"]["owner_response_execution_authorized"] is False
|
||||
assert (
|
||||
"canonical_source"
|
||||
@@ -152,6 +218,14 @@ def test_load_github_target_private_backup_evidence_gate_from_committed_snapshot
|
||||
targets["nexu-io/open-design"]["owner_response_submission_status"]
|
||||
== "not_required"
|
||||
)
|
||||
assert (
|
||||
targets["nexu-io/open-design"]["safe_credential_evidence_submission_status"]
|
||||
== "not_required"
|
||||
)
|
||||
assert (
|
||||
targets["nexu-io/open-design"]["safe_credential_allowed_evidence_ref_types"]
|
||||
== []
|
||||
)
|
||||
|
||||
|
||||
def test_github_target_private_backup_gate_rejects_runtime_authorization(tmp_path):
|
||||
@@ -182,6 +256,45 @@ def test_github_target_private_backup_gate_rejects_owner_response_execution_pack
|
||||
load_latest_github_target_private_backup_evidence_gate(tmp_path)
|
||||
|
||||
|
||||
def test_github_target_private_backup_gate_rejects_raw_payload_redaction_example(
|
||||
tmp_path,
|
||||
):
|
||||
_copy_security_snapshots(tmp_path)
|
||||
owner_response_path = (
|
||||
tmp_path / "github-target-owner-decision-response.snapshot.json"
|
||||
)
|
||||
owner_response = json.loads(owner_response_path.read_text(encoding="utf-8"))
|
||||
owner_response["owner_response_redaction_examples"][0][
|
||||
"stored_raw_payload_allowed"
|
||||
] = True
|
||||
owner_response_path.write_text(json.dumps(owner_response), encoding="utf-8")
|
||||
|
||||
with pytest.raises(ValueError, match="redaction examples"):
|
||||
load_latest_github_target_private_backup_evidence_gate(tmp_path)
|
||||
|
||||
|
||||
def test_github_target_private_backup_gate_requires_safe_credential_blockers(
|
||||
tmp_path,
|
||||
):
|
||||
_copy_security_snapshots(tmp_path)
|
||||
owner_response_path = (
|
||||
tmp_path / "github-target-owner-decision-response.snapshot.json"
|
||||
)
|
||||
owner_response = json.loads(owner_response_path.read_text(encoding="utf-8"))
|
||||
forbidden_payloads = owner_response["owner_response_request_packet"][
|
||||
"forbidden_payloads"
|
||||
]
|
||||
owner_response["owner_response_request_packet"]["forbidden_payloads"] = [
|
||||
payload
|
||||
for payload in forbidden_payloads
|
||||
if payload != "private_clone_url_credential"
|
||||
]
|
||||
owner_response_path.write_text(json.dumps(owner_response), encoding="utf-8")
|
||||
|
||||
with pytest.raises(ValueError, match="forbidden payloads"):
|
||||
load_latest_github_target_private_backup_evidence_gate(tmp_path)
|
||||
|
||||
|
||||
def test_github_target_private_backup_gate_requires_decision_rollup_consistency(
|
||||
tmp_path,
|
||||
):
|
||||
|
||||
@@ -27,6 +27,13 @@ def test_github_target_private_backup_evidence_gate_endpoint_returns_read_only_g
|
||||
assert data["summary"]["github_missing_target_refs_sync_ready_count"] == 0
|
||||
assert data["summary"]["private_backup_verified_count"] == 4
|
||||
assert data["summary"]["private_visibility_verified_count"] == 4
|
||||
assert data["summary"]["safe_credential_evidence_intake_ready"] is True
|
||||
assert data["summary"]["safe_credential_required_redacted_evidence_ref_count"] == 9
|
||||
assert data["summary"]["safe_credential_evidence_ref_rule_count"] == 5
|
||||
assert data["summary"]["safe_credential_redaction_example_count"] == 5
|
||||
assert data["summary"]["safe_credential_forbidden_payload_count"] == 15
|
||||
assert data["summary"]["safe_credential_quarantine_lane_count"] == 1
|
||||
assert data["summary"]["safe_credential_raw_payload_storage_allowed"] is False
|
||||
assert data["summary"]["owner_response_request_ready"] is True
|
||||
assert data["summary"]["owner_response_required_response_item_count"] == 9
|
||||
assert data["summary"]["owner_response_requested_template_count"] == 9
|
||||
@@ -57,5 +64,31 @@ def test_github_target_private_backup_evidence_gate_endpoint_returns_read_only_g
|
||||
assert intake["forbidden_payload_count"] == 15
|
||||
assert intake["execution_authorized"] is False
|
||||
assert intake["not_approval"] is True
|
||||
safe_credential_intake = data["safe_credential_evidence_intake_readiness"]
|
||||
assert (
|
||||
safe_credential_intake["status"]
|
||||
== "ready_to_collect_redacted_evidence_refs_not_credentials"
|
||||
)
|
||||
assert safe_credential_intake["intake_ready"] is True
|
||||
assert safe_credential_intake["required_target_count"] == 9
|
||||
assert safe_credential_intake["required_redacted_evidence_ref_count"] == 9
|
||||
assert safe_credential_intake["evidence_ref_rule_count"] == 5
|
||||
assert safe_credential_intake["redaction_example_count"] == 5
|
||||
assert safe_credential_intake["forbidden_payload_count"] == 15
|
||||
assert safe_credential_intake["quarantine_lane_count"] == 1
|
||||
assert safe_credential_intake["stored_raw_payload_allowed"] is False
|
||||
assert safe_credential_intake["private_clone_url_collection_allowed"] is False
|
||||
assert safe_credential_intake["secret_value_collection_allowed"] is False
|
||||
assert safe_credential_intake["execution_authorized"] is False
|
||||
assert safe_credential_intake["not_approval"] is True
|
||||
assert data["targets"][0]["owner_response_execution_authorized"] is False
|
||||
assert (
|
||||
data["targets"][0]["safe_credential_evidence_submission_status"]
|
||||
== "waiting_redacted_evidence_ref"
|
||||
)
|
||||
assert data["targets"][0]["safe_credential_raw_payload_storage_allowed"] is False
|
||||
assert (
|
||||
data["targets"][0]["safe_credential_private_clone_url_collection_allowed"]
|
||||
is False
|
||||
)
|
||||
assert "192.168.0." not in response.text
|
||||
|
||||
Reference in New Issue
Block a user