story 2-11-security-mapping-ui: implemented and reviewed via bmad-loop
This commit is contained in:
1 parent
b18a84b2c5
commit
4307c1d90d
7 files changed
+1840
-17
No files matched your search
+437
-13
@@ -12,6 +12,9 @@
|
||||
operationsReady: false,
|
||||
decisions: Object.create(null),
|
||||
plan: null,
|
||||
securityChoices: [],
|
||||
securityStatus: 'unresolved',
|
||||
securityByOperation: Object.create(null),
|
||||
filterQuery: '',
|
||||
filterMethod: '',
|
||||
revision: 0,
|
||||
@@ -130,7 +133,13 @@
|
||||
|
||||
function decisionFor(operationKey) {
|
||||
if (!state.decisions[operationKey]) {
|
||||
state.decisions[operationKey] = { action: 'create', targetOperationId: '', confirmedName: '' };
|
||||
state.decisions[operationKey] = {
|
||||
action: 'create',
|
||||
targetOperationId: '',
|
||||
confirmedName: '',
|
||||
securityAlternativeIndex: null,
|
||||
authProfileId: null,
|
||||
};
|
||||
}
|
||||
return state.decisions[operationKey];
|
||||
}
|
||||
@@ -185,6 +194,8 @@
|
||||
}
|
||||
}
|
||||
renderDecisionControls(operation, row);
|
||||
renderSecurityControls(operation, row);
|
||||
updateSecuritySummary();
|
||||
});
|
||||
actionLabel.appendChild(actionSelect);
|
||||
controls.appendChild(actionLabel);
|
||||
@@ -285,6 +296,8 @@
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
updateSecuritySummary();
|
||||
}
|
||||
|
||||
function applyFilters() {
|
||||
@@ -342,6 +355,9 @@
|
||||
missing_servers: 'openapi.finding.missing_servers',
|
||||
multiple_servers: 'openapi.finding.multiple_servers',
|
||||
unsupported_request_body: 'openapi.finding.unsupported_request_body',
|
||||
unsupported_security_scheme: 'openapi.finding.unsupported_security_scheme',
|
||||
unsupported_security_and_requirement: 'openapi.finding.unsupported_security_and_requirement',
|
||||
auth_profile_required: 'openapi.error.auth_profile_required',
|
||||
operation_name_renamed: 'openapi.finding.operation_name_renamed',
|
||||
operation_name_conflict: 'openapi.finding.operation_name_conflict',
|
||||
weak_tool_description: 'openapi.finding.weak_tool_description',
|
||||
@@ -462,6 +478,303 @@
|
||||
});
|
||||
}
|
||||
|
||||
var SECURITY_STATUS_KEYS = {
|
||||
no_auth: 'openapi.security.status_no_auth',
|
||||
required: 'openapi.security.status_required',
|
||||
unresolved: 'openapi.security.status_unresolved',
|
||||
unverified: 'openapi.security.status_unverified',
|
||||
resolved: 'openapi.security.status_resolved',
|
||||
blocked: 'openapi.security.status_blocked',
|
||||
};
|
||||
var SECURITY_PLAN_ERROR_CODES = [
|
||||
'import_plan_auth_unavailable',
|
||||
'import_plan_auth_incompatible',
|
||||
'import_plan_security_alternative_required',
|
||||
];
|
||||
|
||||
function securityStatusLabel(status) {
|
||||
return tKey(SECURITY_STATUS_KEYS[status] || SECURITY_STATUS_KEYS.unresolved);
|
||||
}
|
||||
|
||||
function renderSecurityStatus() {
|
||||
var node = qs('openapi-import-security-status');
|
||||
if (!node) return;
|
||||
node.textContent = securityStatusLabel(state.securityStatus);
|
||||
}
|
||||
|
||||
function setSecurityStatus(status) {
|
||||
state.securityStatus = status;
|
||||
renderSecurityStatus();
|
||||
}
|
||||
|
||||
function securityOperationNode(operationKey) {
|
||||
// Compare dataset values against a constant selector: imported operation
|
||||
// keys are untrusted and must never be interpolated into a CSS selector.
|
||||
var nodes = document.querySelectorAll('[data-openapi-security-op-status]');
|
||||
for (var i = 0; i < nodes.length; i += 1) {
|
||||
if (nodes[i].dataset.openapiSecurityOpStatus === operationKey) return nodes[i];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function renderOperationSecurityStatus(operationKey) {
|
||||
var node = securityOperationNode(operationKey);
|
||||
if (!node) return;
|
||||
var status = state.securityByOperation[operationKey] || 'unresolved';
|
||||
node.dataset.status = status;
|
||||
node.textContent = securityStatusLabel(status);
|
||||
}
|
||||
|
||||
function setOperationSecurityStatus(operationKey, status) {
|
||||
state.securityByOperation[operationKey] = status;
|
||||
renderOperationSecurityStatus(operationKey);
|
||||
}
|
||||
|
||||
// Summary only: the per-operation nodes carry the authority, this aggregate
|
||||
// id reports whether any selected operation still needs attention.
|
||||
function updateSecuritySummary() {
|
||||
var selected = new Set(selectedKeys());
|
||||
var statuses = [];
|
||||
importOperations().forEach(function(operation) {
|
||||
if (!selected.has(operation.key)) return;
|
||||
statuses.push(state.securityByOperation[operation.key] || baselineSecurityStatus(operation));
|
||||
});
|
||||
var summary = 'unresolved';
|
||||
if (statuses.indexOf('blocked') >= 0) summary = 'blocked';
|
||||
else if (statuses.indexOf('required') >= 0) summary = 'required';
|
||||
else if (statuses.indexOf('unverified') >= 0) summary = 'unverified';
|
||||
else if (statuses.indexOf('resolved') >= 0) summary = 'resolved';
|
||||
else if (statuses.length && statuses.every(function(status) { return status === 'no_auth'; })) summary = 'no_auth';
|
||||
setSecurityStatus(summary);
|
||||
}
|
||||
|
||||
function securityAlternativesFor(operation) {
|
||||
var requirements = operation && operation.security_requirements;
|
||||
return requirements && Array.isArray(requirements.alternatives) ? requirements.alternatives : [];
|
||||
}
|
||||
|
||||
function alternativeFor(operation, index) {
|
||||
if (index === null || index === undefined) return null;
|
||||
return securityAlternativesFor(operation)[Number(index)] || null;
|
||||
}
|
||||
|
||||
function isAnonymousAlternative(alternative) {
|
||||
if (!alternative || alternative.supported === false) return false;
|
||||
var schemes = Array.isArray(alternative.schemes) ? alternative.schemes : [];
|
||||
return schemes.length === 0;
|
||||
}
|
||||
|
||||
function operationRequiresAuth(operation) {
|
||||
return securityAlternativesFor(operation).some(function(alternative) {
|
||||
return alternative && alternative.supported !== false
|
||||
&& Array.isArray(alternative.schemes) && alternative.schemes.length > 0;
|
||||
});
|
||||
}
|
||||
|
||||
function securityProfilesFor(operation, alternativeIndex) {
|
||||
var profiles = [];
|
||||
(state.securityChoices || []).forEach(function(choice) {
|
||||
if (!choice || choice.operation_key !== operation.key) return;
|
||||
// Filter to the exact selected alternative. While no alternative is
|
||||
// chosen the safe union supports profile-first selection and lets the
|
||||
// API own compatibility validation.
|
||||
if (alternativeIndex !== null && alternativeIndex !== undefined
|
||||
&& Number(choice.alternative_index) !== Number(alternativeIndex)) return;
|
||||
if (Array.isArray(choice.profiles)) profiles = profiles.concat(choice.profiles);
|
||||
});
|
||||
// Keep a stable order across alternatives: first occurrence wins.
|
||||
var seen = {};
|
||||
return profiles.filter(function(profile) {
|
||||
if (!profile || typeof profile.id !== 'string' || !profile.id || seen[profile.id]) return false;
|
||||
seen[profile.id] = true;
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
// Local expectation only; resolved/blocked never originate here.
|
||||
function baselineSecurityStatus(operation) {
|
||||
var alternatives = securityAlternativesFor(operation);
|
||||
if (!alternatives.length) return 'no_auth';
|
||||
var decision = decisionFor(operation.key);
|
||||
if (decision.action === 'skip') return 'unresolved';
|
||||
if (!alternatives.some(function(alternative) { return alternative && alternative.supported !== false; })) {
|
||||
return 'blocked';
|
||||
}
|
||||
if (!operationRequiresAuth(operation)) return 'no_auth';
|
||||
var alternative = alternativeFor(operation, decision.securityAlternativeIndex);
|
||||
if (isAnonymousAlternative(alternative)) return 'unresolved';
|
||||
if (decision.authProfileId) return 'unresolved';
|
||||
return 'required';
|
||||
}
|
||||
|
||||
function resetSecurityStatuses() {
|
||||
importOperations().forEach(function(operation) {
|
||||
state.securityByOperation[operation.key] = baselineSecurityStatus(operation);
|
||||
renderOperationSecurityStatus(operation.key);
|
||||
});
|
||||
updateSecuritySummary();
|
||||
}
|
||||
|
||||
function operationRowFor(operation) {
|
||||
return Array.from(document.querySelectorAll('.openapi-import-operation')).find(function(row) {
|
||||
var input = row.querySelector('[data-openapi-operation]');
|
||||
return input && input.value === operation.key;
|
||||
}) || null;
|
||||
}
|
||||
|
||||
function invalidatePendingPlan() {
|
||||
// Even without a stored plan a prior blocked state must be cleared: the
|
||||
// edited selection is unverified until the next plan response arrives.
|
||||
if (state.plan) {
|
||||
state.plan = null;
|
||||
qs('openapi-import-plan-confirmation').hidden = true;
|
||||
qs('openapi-import-plan-counts').replaceChildren();
|
||||
qs('openapi-import-plan-candidates').replaceChildren();
|
||||
qs('openapi-import-versioning-consequences').hidden = true;
|
||||
qs('openapi-import-plan-blocked-help').hidden = true;
|
||||
}
|
||||
resetSecurityStatuses();
|
||||
}
|
||||
|
||||
function renderSecurityControls(operation, row) {
|
||||
var previous = row.querySelector('.openapi-import-security');
|
||||
if (previous) previous.remove();
|
||||
|
||||
var decision = decisionFor(operation.key);
|
||||
var alternatives = securityAlternativesFor(operation);
|
||||
|
||||
if (decision.action === 'skip') {
|
||||
// A skipped operation keeps the existing operation untouched: no
|
||||
// security binding may be attached, so clear it instead of trapping the
|
||||
// user in a local validation error.
|
||||
decision.authProfileId = null;
|
||||
decision.securityAlternativeIndex = null;
|
||||
setOperationSecurityStatus(operation.key, 'unresolved');
|
||||
return;
|
||||
}
|
||||
|
||||
var wrapper = document.createElement('div');
|
||||
wrapper.className = 'openapi-import-security';
|
||||
|
||||
var statusNode = document.createElement('span');
|
||||
statusNode.className = 'openapi-import-security-op-status';
|
||||
statusNode.setAttribute('data-openapi-security-op-status', operation.key);
|
||||
statusNode.setAttribute('data-testid', 'openapi-security-op-status');
|
||||
// Announce per-operation changes even when the aggregate text is unchanged.
|
||||
statusNode.setAttribute('role', 'status');
|
||||
statusNode.setAttribute('aria-live', 'polite');
|
||||
wrapper.appendChild(statusNode);
|
||||
|
||||
if (alternatives.length) {
|
||||
var controls = document.createElement('div');
|
||||
controls.className = 'openapi-import-security-controls';
|
||||
|
||||
// Only the alternative index and the typed profile id are stored locally.
|
||||
// The API remains the authority for OR/AND semantics and compatibility.
|
||||
var alternativeLabel = document.createElement('label');
|
||||
var alternativeSelect = document.createElement('select');
|
||||
alternativeLabel.textContent = tKey('openapi.security.alternative_label');
|
||||
alternativeSelect.dataset.openapiSecurityAlternative = operation.key;
|
||||
|
||||
var alternativePlaceholder = document.createElement('option');
|
||||
alternativePlaceholder.value = '';
|
||||
alternativePlaceholder.textContent = tKey('openapi.security.alternative_placeholder');
|
||||
alternativeSelect.appendChild(alternativePlaceholder);
|
||||
|
||||
var findingsNode = null;
|
||||
alternatives.forEach(function(alternative, index) {
|
||||
var option = document.createElement('option');
|
||||
var schemes = alternative && Array.isArray(alternative.schemes) ? alternative.schemes : [];
|
||||
option.value = String(index);
|
||||
option.textContent = schemes.length ? schemes.join(' + ') : tKey('openapi.security.no_auth');
|
||||
if (alternative && alternative.supported === false) {
|
||||
option.disabled = true;
|
||||
option.textContent += ' · ' + tKey('openapi.security.unsupported');
|
||||
var finding = Array.isArray(alternative.findings) && alternative.findings[0];
|
||||
// Surface the blocker as a safe, localized message next to the control.
|
||||
if (finding) {
|
||||
if (!findingsNode) {
|
||||
findingsNode = document.createElement('span');
|
||||
findingsNode.className = 'openapi-import-security-findings';
|
||||
}
|
||||
var findingSpan = document.createElement('span');
|
||||
findingSpan.className = 'openapi-import-finding openapi-import-finding-warning';
|
||||
findingSpan.textContent = findingMessage({ code: finding });
|
||||
findingsNode.appendChild(findingSpan);
|
||||
}
|
||||
}
|
||||
alternativeSelect.appendChild(option);
|
||||
});
|
||||
|
||||
alternativeSelect.value = decision.securityAlternativeIndex === null
|
||||
? ''
|
||||
: String(decision.securityAlternativeIndex);
|
||||
alternativeSelect.addEventListener('change', function() {
|
||||
// Switching the alternative invalidates the previous profile binding and
|
||||
// any server-confirmed plan: the API revalidates the current selection.
|
||||
decision.securityAlternativeIndex = alternativeSelect.value === ''
|
||||
? null
|
||||
: Number(alternativeSelect.value);
|
||||
decision.authProfileId = null;
|
||||
invalidatePendingPlan();
|
||||
renderSecurityControls(operation, row);
|
||||
});
|
||||
alternativeLabel.appendChild(alternativeSelect);
|
||||
controls.appendChild(alternativeLabel);
|
||||
if (findingsNode) controls.appendChild(findingsNode);
|
||||
|
||||
var selectedAlternative = alternativeFor(operation, decision.securityAlternativeIndex);
|
||||
var anonymous = isAnonymousAlternative(selectedAlternative);
|
||||
var profiles = securityProfilesFor(operation, decision.securityAlternativeIndex);
|
||||
|
||||
// An anonymous alternative must offer no profile at all.
|
||||
if (!anonymous) {
|
||||
var profileLabel = document.createElement('label');
|
||||
var profileSelect = document.createElement('select');
|
||||
profileLabel.textContent = tKey('openapi.security.profile_label');
|
||||
profileSelect.dataset.openapiSecurityProfile = operation.key;
|
||||
|
||||
var profilePlaceholder = document.createElement('option');
|
||||
profilePlaceholder.value = '';
|
||||
profilePlaceholder.textContent = tKey('openapi.security.profile_placeholder');
|
||||
profileSelect.appendChild(profilePlaceholder);
|
||||
|
||||
profiles.forEach(function(profile) {
|
||||
// Safe metadata only: id, name, kind. Never credential material.
|
||||
var option = document.createElement('option');
|
||||
option.value = profile.id;
|
||||
option.textContent = String(profile.name || profile.id);
|
||||
if (profile.kind) option.textContent += ' · ' + profile.kind;
|
||||
profileSelect.appendChild(option);
|
||||
});
|
||||
|
||||
var emptyProfiles = decision.securityAlternativeIndex !== null
|
||||
&& selectedAlternative && selectedAlternative.supported !== false
|
||||
&& !anonymous && profiles.length === 0;
|
||||
if (emptyProfiles) {
|
||||
profileSelect.disabled = true;
|
||||
var guidance = document.createElement('span');
|
||||
guidance.className = 'openapi-import-security-guidance';
|
||||
guidance.textContent = tKey('openapi.security.empty_profiles');
|
||||
profileLabel.appendChild(guidance);
|
||||
}
|
||||
|
||||
profileSelect.value = decision.authProfileId || '';
|
||||
profileSelect.addEventListener('change', function() {
|
||||
decision.authProfileId = profileSelect.value || null;
|
||||
invalidatePendingPlan();
|
||||
});
|
||||
profileLabel.appendChild(profileSelect);
|
||||
controls.appendChild(profileLabel);
|
||||
}
|
||||
|
||||
wrapper.appendChild(controls);
|
||||
}
|
||||
|
||||
row.appendChild(wrapper);
|
||||
setOperationSecurityStatus(operation.key, baselineSecurityStatus(operation));
|
||||
}
|
||||
|
||||
function renderPreview(response) {
|
||||
var preview = response.preview;
|
||||
var count = (preview.groups || []).reduce(function(sum, group) {
|
||||
@@ -475,6 +788,10 @@
|
||||
state.existingOperations = [];
|
||||
state.operationsReady = false;
|
||||
state.decisions = Object.create(null);
|
||||
state.securityChoices = Array.isArray(response.security_profile_choices)
|
||||
? response.security_profile_choices
|
||||
: [];
|
||||
state.securityByOperation = Object.create(null);
|
||||
importOperations().forEach(function(operation) { decisionFor(operation.key); });
|
||||
state.filterQuery = '';
|
||||
state.filterMethod = '';
|
||||
@@ -543,6 +860,7 @@
|
||||
}
|
||||
|
||||
renderDecisionControls(operation, row);
|
||||
renderSecurityControls(operation, row);
|
||||
groupNode.appendChild(row);
|
||||
});
|
||||
|
||||
@@ -560,6 +878,7 @@
|
||||
input.addEventListener('change', updateSelection);
|
||||
});
|
||||
applyFilters();
|
||||
resetSecurityStatuses();
|
||||
}
|
||||
|
||||
function validateFile(file) {
|
||||
@@ -592,6 +911,9 @@
|
||||
state.existingOperations = [];
|
||||
state.operationsReady = false;
|
||||
state.decisions = Object.create(null);
|
||||
state.securityChoices = [];
|
||||
state.securityStatus = 'unresolved';
|
||||
state.securityByOperation = Object.create(null);
|
||||
state.plan = null;
|
||||
state.applyRequest = null;
|
||||
state.applyMetadata = [];
|
||||
@@ -607,6 +929,7 @@
|
||||
qs('openapi-import-versioning-consequences').hidden = true;
|
||||
qs('openapi-import-plan-blocked-help').hidden = true;
|
||||
qs('openapi-import-groups').replaceChildren();
|
||||
renderSecurityStatus();
|
||||
qs('openapi-import-result').hidden = true;
|
||||
qs('openapi-import-result').replaceChildren();
|
||||
updateSelection();
|
||||
@@ -665,6 +988,9 @@
|
||||
document.querySelectorAll('.openapi-import-decision-controls select, .openapi-import-decision-controls input').forEach(function(input) {
|
||||
input.disabled = locked;
|
||||
});
|
||||
document.querySelectorAll('.openapi-import-security-controls select, .openapi-import-security-controls input').forEach(function(input) {
|
||||
input.disabled = locked;
|
||||
});
|
||||
}
|
||||
|
||||
function lockPlanEditing(locked) {
|
||||
@@ -684,6 +1010,9 @@
|
||||
document.querySelectorAll('.openapi-import-decision-controls select, .openapi-import-decision-controls input').forEach(function(input) {
|
||||
input.disabled = locked;
|
||||
});
|
||||
document.querySelectorAll('.openapi-import-security-controls select, .openapi-import-security-controls input').forEach(function(input) {
|
||||
input.disabled = locked;
|
||||
});
|
||||
}
|
||||
|
||||
function markApplyOutcomeUnknown(options) {
|
||||
@@ -743,6 +1072,9 @@
|
||||
'openapi_upload.storage_unavailable': 'openapi.error.storage_unavailable',
|
||||
'openapi_upload.source_integrity': 'openapi.error.source_integrity',
|
||||
'openapi_upload.source_unavailable': 'openapi.error.source_unavailable',
|
||||
'import_plan_auth_unavailable': 'openapi.error.auth_unavailable',
|
||||
'import_plan_auth_incompatible': 'openapi.error.auth_incompatible',
|
||||
'import_plan_security_alternative_required': 'openapi.error.security_alternative_required',
|
||||
};
|
||||
var message = tKey(known[error && error.code] || fallback);
|
||||
var identifiers = [];
|
||||
@@ -796,11 +1128,11 @@
|
||||
state.existingOperations = operationResponse.items;
|
||||
state.operationsReady = true;
|
||||
importOperations().forEach(function(operation) {
|
||||
var row = Array.from(document.querySelectorAll('.openapi-import-operation')).find(function(candidateRow) {
|
||||
var input = candidateRow.querySelector('[data-openapi-operation]');
|
||||
return input && input.value === operation.key;
|
||||
});
|
||||
if (row) renderDecisionControls(operation, row);
|
||||
var row = operationRowFor(operation);
|
||||
if (row) {
|
||||
renderDecisionControls(operation, row);
|
||||
renderSecurityControls(operation, row);
|
||||
}
|
||||
});
|
||||
qs('openapi-import-create').disabled = false;
|
||||
setStatus(tKey('openapi.status.preview_ready'));
|
||||
@@ -997,6 +1329,33 @@
|
||||
var versioningNode = qs('openapi-import-versioning-consequences');
|
||||
var counts = plan.counts || {};
|
||||
var hasBlocked = (Number(counts.blocked) || 0) > 0;
|
||||
var operationsByKey = Object.create(null);
|
||||
importOperations().forEach(function(operation) { operationsByKey[operation.key] = operation; });
|
||||
|
||||
// The plan API is the sole authority for each operation's binding outcome.
|
||||
(Array.isArray(plan.candidates) ? plan.candidates : []).forEach(function(candidate) {
|
||||
if (!candidate || !candidate.key) return;
|
||||
var operation = operationsByKey[candidate.key];
|
||||
var alternativeIndex = candidate.security_alternative_index;
|
||||
var anonymous = alternativeIndex !== null && alternativeIndex !== undefined
|
||||
&& isAnonymousAlternative(alternativeFor(operation, alternativeIndex));
|
||||
var status;
|
||||
if (candidate.state === 'blocked') {
|
||||
status = 'blocked';
|
||||
} else if (candidate.state === 'actionable') {
|
||||
// Only a genuine auth binding confirmed by the API is resolved; a
|
||||
// no-auth/anonymous or unbound candidate must never read as resolved.
|
||||
if (candidate.auth_profile_id) status = 'resolved';
|
||||
else if (operation && !operationRequiresAuth(operation)) status = 'no_auth';
|
||||
else if (anonymous) status = 'no_auth';
|
||||
else status = 'unresolved';
|
||||
} else {
|
||||
// Excluded/skipped candidates keep the operation untouched.
|
||||
status = 'unresolved';
|
||||
}
|
||||
setOperationSecurityStatus(candidate.key, status);
|
||||
});
|
||||
updateSecuritySummary();
|
||||
var countSpecs = [
|
||||
['selected', 'openapi.plan.selected'],
|
||||
['excluded', 'openapi.plan.excluded'],
|
||||
@@ -1241,6 +1600,8 @@
|
||||
state.plan = null;
|
||||
qs('openapi-import-plan-confirmation').hidden = true;
|
||||
lockPlanEditing(false);
|
||||
// A rejected/repreview Apply voids the prior resolved security review.
|
||||
resetSecurityStatuses();
|
||||
if (!qs('openapi-import-modal').hidden) {
|
||||
if (recovery === 'repreview_required') {
|
||||
setStatus(tKey('openapi.plan.repreview'), true, true);
|
||||
@@ -1308,6 +1669,16 @@
|
||||
var selectedSet = new Set(keys);
|
||||
var decisions = [];
|
||||
var invalidDecision = null;
|
||||
importOperations().forEach(function(operation) {
|
||||
if (!selectedSet.has(operation.key)) return;
|
||||
var decision = decisionFor(operation.key);
|
||||
// Skip decisions keep the existing operation untouched: no security
|
||||
// binding may be attached to them.
|
||||
if (decision.action === 'skip'
|
||||
&& (decision.authProfileId || decision.securityAlternativeIndex !== null)) {
|
||||
invalidDecision = 'openapi.error.security_with_skip';
|
||||
}
|
||||
});
|
||||
importOperations().forEach(function(operation) {
|
||||
if (!selectedSet.has(operation.key) || invalidDecision) return;
|
||||
var decision = decisionFor(operation.key);
|
||||
@@ -1332,7 +1703,19 @@
|
||||
invalidDecision = 'openapi.error.decision_action';
|
||||
return;
|
||||
}
|
||||
if (decision.action !== 'create') decisions.push(output);
|
||||
// Security binding is a typed reference only: alternative index and,
|
||||
// when chosen, the profile id. Resolution stays server-side.
|
||||
if (decision.action !== 'skip') {
|
||||
if (decision.authProfileId) output.auth_profile_id = decision.authProfileId;
|
||||
if (decision.securityAlternativeIndex !== null) {
|
||||
output.security_alternative_index = decision.securityAlternativeIndex;
|
||||
}
|
||||
}
|
||||
if (decision.action !== 'create'
|
||||
|| decision.authProfileId
|
||||
|| decision.securityAlternativeIndex !== null) {
|
||||
decisions.push(output);
|
||||
}
|
||||
});
|
||||
if (invalidDecision) {
|
||||
setStatus(tKey(invalidDecision), true, true);
|
||||
@@ -1386,6 +1769,16 @@
|
||||
}
|
||||
setStatus(errorStatus(error, 'openapi.error.plan'), true, true);
|
||||
showRetry(true);
|
||||
// A typed API rejection of a security binding is authoritative blocked;
|
||||
// a transport/network failure only means the selection is unverified.
|
||||
var securityRejection = Number.isInteger(error && error.status)
|
||||
&& error.status >= 400 && error.status < 500
|
||||
&& SECURITY_PLAN_ERROR_CODES.indexOf(String(error.code)) >= 0;
|
||||
importOperations().forEach(function(operation) {
|
||||
if (!selectedSet.has(operation.key) || !securityAlternativesFor(operation).length) return;
|
||||
setOperationSecurityStatus(operation.key, securityRejection ? 'blocked' : 'unverified');
|
||||
});
|
||||
updateSecuritySummary();
|
||||
} finally {
|
||||
if (state.planController === controller) {
|
||||
state.planController = null;
|
||||
@@ -1422,6 +1815,9 @@
|
||||
function backToImportSelection() {
|
||||
if (state.applyInFlight || state.applyOutcomeUnknown) return;
|
||||
state.plan = null;
|
||||
// Returning to editing voids the previous review: revalidation is done by
|
||||
// the next plan request.
|
||||
resetSecurityStatuses();
|
||||
qs('openapi-import-plan-confirmation').hidden = true;
|
||||
qs('openapi-import-plan-counts').replaceChildren();
|
||||
qs('openapi-import-plan-candidates').replaceChildren();
|
||||
@@ -1530,6 +1926,18 @@
|
||||
|
||||
renderFileName();
|
||||
|
||||
// Dedicated screen-reader output for the API-authoritative binding state.
|
||||
var groupsNode = qs('openapi-import-groups');
|
||||
if (!qs('openapi-import-security-status') && groupsNode && groupsNode.parentNode) {
|
||||
var securityStatusNode = document.createElement('div');
|
||||
securityStatusNode.id = 'openapi-import-security-status';
|
||||
securityStatusNode.className = 'openapi-import-security-status';
|
||||
securityStatusNode.setAttribute('data-testid', 'openapi-security-status');
|
||||
securityStatusNode.setAttribute('role', 'status');
|
||||
securityStatusNode.setAttribute('aria-live', 'polite');
|
||||
groupsNode.parentNode.insertBefore(securityStatusNode, groupsNode);
|
||||
}
|
||||
|
||||
qs('openapi-import-file-select').addEventListener('click', function(event) {
|
||||
event.preventDefault();
|
||||
qs('openapi-import-file').click();
|
||||
@@ -1601,14 +2009,30 @@
|
||||
setStatus(tKey('openapi.status.context_changed'));
|
||||
}
|
||||
}
|
||||
function handleLanguageChange() {
|
||||
if (!qs('openapi-import-modal').hidden && state.plan && !state.applyInFlight && !state.applyOutcomeUnknown) {
|
||||
renderImportPlan(state.plan);
|
||||
setStatus(tKey('openapi.status.plan_ready'));
|
||||
return;
|
||||
}
|
||||
function handleLanguageChange() {
|
||||
// While an Apply owns the locked controls, re-rendering would re-enable
|
||||
// them. Route straight to the context-change path, which marks the apply
|
||||
// outcome unknown and keeps the controls locked.
|
||||
if (state.applyInFlight || state.applyController || (state.applyOutcomeUnknown && state.applyRequest)) {
|
||||
renderSecurityStatus();
|
||||
invalidateForContext();
|
||||
return;
|
||||
}
|
||||
importOperations().forEach(function(operation) {
|
||||
var row = operationRowFor(operation);
|
||||
if (row) {
|
||||
renderDecisionControls(operation, row);
|
||||
renderSecurityControls(operation, row);
|
||||
}
|
||||
});
|
||||
if (!qs('openapi-import-modal').hidden && state.plan) {
|
||||
renderImportPlan(state.plan);
|
||||
setStatus(tKey('openapi.status.plan_ready'));
|
||||
return;
|
||||
}
|
||||
updateSecuritySummary();
|
||||
invalidateForContext();
|
||||
}
|
||||
window.addEventListener('crank:langchange', handleLanguageChange);
|
||||
window.addEventListener('crank:workspacechange', function(event) {
|
||||
if (!qs('openapi-import-modal').hidden) {
|
||||
|
||||
Reference in new issue
Block a user