Repository navigation
fix: check the ids that the other delete functions put into a request path - #1218
Merged
Merged
Conversation
assertSecretStoreId checks the id of a secret store unless the store is of the type that has one store and no id: the request for such a store names the type and ends there, so its id is not sent and is not checked. The type is checked by assertRequestSegment. Internal, not on the facade. Refs #1192 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The delete functions of agents, journeys and nodes, scripts, the cloud environment (secrets and their versions, variables, certificates, CSRs, log API keys, telemetry, signing keys and IdP adapters), IGA (certification templates, events, glossary schemas, request forms and types, workflows), secret stores and their mappings, OAuth2 clients, trusted issuers, policies, policy sets, resource types, realms, circles of trust, social identity providers, SAML2 providers, applications, managed and system objects and internal roles check the id before they send any request, as those of IDM config and services do. A function that deletes what a list holds checks each listed id as one item, so a refused id is one failed item like a delete that fails with HTTP 500. The facade walk lists no function as pending any more; the scenarios of the lists run each function twice, with a refused id and with a failing one, and compare what was deleted and what was reported. Refs #1192 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…y delete function Refs #1192 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…sted The facade cannot give deleteNode a version, and does not call the ops function deleteSecret; deleteSecretStoreMappings, pruneVersionsOfSecret, deleteWorkflow with a result callback and deleteCustomNode by its display name need ids of their own. The check of the secret id of a version is made once, when the prune begins. Refs #1192 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Refs #1192 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The catch of a rejected call and the print handler of the journey test had types that tsc over the test files refuses. Nothing is asserted differently. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
deleteJourneys was listed with the functions that try every item and throw one error after the last one. It resolves with the status of each journey, a refused or failed journey has status error and an error, and a result callback gets no error argument. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…on and reads included deleteCertificates with force sent a PATCH to deactivate an active certificate that the tenant listed with such an id before the delete refused it, deleteJourney read a container node by such an id before the node was deleted, and deleteAIAgents sent the listed id in the filter of a read. Each is now checked before the first request for it: the certificate is skipped by the deactivation and refused by its delete, the container node is a failed node that is not read, and the agent is refused before it is looked up. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…a custom node and a script that is not found deleteSecretStore, deleteSecretStoreMapping and deleteSecretStoreMappings without a type find the type and delete. deleteCustomNode checks and sends the id with the -1 that it adds. deleteScriptByName for a name that no script has fails with the text it had and deletes nothing. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The workflow id goes into the path of the two reads that look up the workflows, so it is checked first, before any request. No id goes into the path of the removal: it is a POST built from what the tenant lists, and the filters that the other ids go into are out of scope. The function has a row in the walk now and is no longer exempt. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…t and deleteManagedSystemObjects The type goes into the path of the query that reads the objects and of each delete, so it is checked before the first request. The real values (alpha_user, svcacct, teammember) are one name each. The mocked test of deleteManagedSystemObject passed a type with slashes, which is no type of that function; it passes teammember now. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ete functions and of a comment "A listed X that the tenant lists" said list twice and "A event" had the wrong article; the sentences of the single deletes of an object that is found by a name say that no delete request is sent. The comment on the secret store types that have no id says only what the code does. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…xt of a refused container node and an empty workflow id deleteCertificates with force on a list of active, inactive and refused certificates deactivates only the active ones with a good id, deletes every good one and sends nothing for a refused one. The verbose text for a container node whose id is not one name holds no id. An empty workflow id of deleteOrphanedRequestFormAssignments is none: it is not refused and sends what a call without a workflow id sends. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Second half of the delete functions that check the id they put into the path of a request (the first half, #1217, did IDM configuration entities, connectors, mappings, email templates and services). A
delete*function that is given an id that is not one name (empty,.or.., a slash, a backslash,?,#,%, a control character, a lone surrogate, a blank at either end, a leading;) refuses it before it sends any request, a read included, and throws aFrodoErrorwhose message says what an id has to be and does not hold the id. A function that deletes what a list holds, or an object that it finds by a name, checks each id that the tenant lists as one item: a refused id is one failed item, like an item whose delete fails with HTTP 500, and the other items are tried or not exactly as they are for that failure. The rule is the one that a push already applies to the ids of a file set: https://github.com/rockcarver/frodo-lib/blob/main/decisions/0021-crudq-naming-for-facade-methods-and-pull-and-push-as-file-set-verbs.md (a safe segment is one name that no request layer or server reads as more).With this change every function of the
frodofacade whose name starts withdeleteis accounted for by a test: a row for the ids that a caller gives, a scenario for the ids that a tenant lists, or a reason why it has no id in the path of a request. The list of functions that were not covered yet is empty, and a function that is added without one of the three fails the walk.Part of #1192 (its delete half; the reads and writes of services that also put an id into a path are a follow-up)
Part of rockcarver/frodo-cli#1264
What each family checks
deleteAgents,deleteAgent, and the four of each of the identity gateway, Java, web and AI agents): the id that the tenant lists, once, in the one function that every agent delete goes through;deleteAIAgentschecks the id before it looks the agent up.deleteJourney(a refused id comes back in the status,error, and nothing is requested or shown; a node of the deleted journey with such an id is a failed node, and a container node with such an id is not read),deleteJourneys(it reports in the status of each journey and never throws, as before),deleteNode(node id, type, version of the type),deleteCustomNode(the id that is sent, which is the one given and-1; and the id that the tenant lists for a display name),deleteCustomNodes.deleteScript,deleteScriptByName(it looks the script up by name and deletes it by the id that the tenant lists, which is now checked in between; two requests, as before),deleteScripts.deleteSecretanddeleteVersionOfSecreton the facade (which call the api layer, so they check inline), the opsdeleteSecret,pruneVersionsOfSecret(the secret id first, each listed version),deleteVariable,deleteCertificate(s)(deleteCertificateswith force does not deactivate a certificate with such an id either: nothing is sent for it),deleteCSR(s),deleteLogApiKey(s),deleteTelemetry(each listed exporter),deleteSigningKeyPairById,deleteSigningKeyPairCertificate,deleteIdpAdapterById,deleteAdminFederationProvider.deleteWorkflowrefuses once before the draft and the published workflow;deleteOrphanedRequestFormAssignmentsrefuses a workflow id that is not one name (it goes into the path of two reads). The other ids that it takes select which assignments are looked at, and the assignments are removed with the body of a POST built from what the tenant lists, so no id goes into the path of the removal; the filters of the reads are out of scope.EnvironmentAndSystemPropertySecretStore, whose request names the type and ends there), mapping id; the adapter of the AI agent feature that calls the api layer checks its own ids.deleteApplicationbefore the glossary of an IGA application is deleted,deleteApplicationOwnedObjectsById; the objects that an application owns go through the delete function of their own type, so a refused one is reported as failed), managed objects (type and id), managed system objects (type and id), system objects (system, type, id), internal roles.importServiceandimportServiceswith the option that cleans first delete throughdeleteFullService, so a service id that is not one name (or, for a global service,federation/<name>) is refused before any request (it is inMIGRATION.md).Exempt, with the reason (each is in the walk with it):
frodo.theme.deleteTheme,deleteThemeByName,deleteThemes(the wholeui/themerealmentity is read and rewritten, no id goes into a path);frodo.idm.staticUserMapping.deleteStaticUserMapping(changed in memory);frodo.oauth2oidc.provider.deleteOAuth2Provider(no id);frodo.idm.remoteProxy.deleteRemoteProxyanddeleteRemoteProxies(a stricter name check of their own);frodo.oauth2oidc.cimd.deleteCIMDProfileanddeleteCIMDProfiles(a check of their own, and the api layer encodes the id); the four functions that touch no request (deleteConnectionProfile,deleteConnectionProfileAlias,deleteHost,deleteDeepByKey).What each commit does
feat: add the check of the id of a secret store:assertSecretStoreIdin the internal helper module, with its unit test.fix: refuse an id that is not one name in the remaining delete functions: the checks, as the first statement of each function (before the first read), and the tests: the rows of the facade walk (an id that the caller gives: each hostile value; nothing is requested and no message holds the id), and the scenarios ofDeleteFunctions.bulkItems.unit.test.ts, which run each list function twice against a fake tenant, once with a refused id and once with an item whose delete fails with HTTP 500, and compare what was deleted, whether the call was rejected and how many failures it reports.docs: extend the MIGRATION.md entry of the checked delete ids to every delete function.test: cover the checks that the first runs of the mutants showed untestedandtest: name the rule of a row of the walk by what it is.origin/main.After the first review and QA:
test: fix the types of the tests of the delete functions:tscover the test files refused six places of the walk (a catch that gave a union, a print handler); nothing is asserted differently.docs: say that deleteJourneys never throws in MIGRATION.md:deleteJourneyswas listed with the functions that throw one error after the last item. It resolves with the status of every journey; a refused or failed journey hasstatus: 'error'and anerror, and a result callback gets no error argument.fix: send no request for a listed id that is not one name, deactivation and reads included:deleteCertificateswith force sent a PATCH to deactivate an active certificate that the tenant lists with such an id before its delete refused it (the certificate is skipped by the deactivation now);deleteJourneyread a container node by such an id (it is a failed node that is not read);deleteAIAgentssent the listed id in the filter of a read (it is refused before the agent is looked up). Each has a test that sends nothing for the refused id while the ids around it are handled as before.test: cover the calls that leave an optional argument out, the id of a custom node and a script that is not found:deleteSecretStore,deleteSecretStoreMappinganddeleteSecretStoreMappingswithout a type;deleteCustomNodechecks and sends the id with the-1that it adds;deleteScriptByNamefor a name that no script has.fix: check the workflow id of deleteOrphanedRequestFormAssignments: the workflow id goes into the path of two reads; no id goes into the path of the removal (a POST built from what the tenant lists), and the filters that the other ids go into are out of scope. The function has a row now and is no longer exempt.fix: check the type of deleteManagedObjects, deleteManagedSystemObject and deleteManagedSystemObjects: the type was sent in the query of the read before any check.docs: correct the wording of the @throws sentences of the checked delete functions and of a comment.origin/main(the release commit of 5.0.0-61).test: cover a mix of active and inactive certificates, the verbose text of a refused container node and an empty workflow id: three tests added to the walk, no change to the code.deleteCertificateswith force on a list of active, inactive and refused certificates deactivates only the active ones with a good id, deletes every good one and sends nothing for a refused one; the verbose text of a refused container node holds no id; an empty workflow id ofdeleteOrphanedRequestFormAssignmentsis none (it is not refused and sends what a call without a workflow id sends).Decisions taken
deleteSecretanddeleteVersionOfSecret, the delete of a version inpruneVersionsOfSecret, the adapter of the AI agent feature), the check is made there. Reversible: yes.FrodoErrorcode and no new public name;assertSecretStoreIdis internal. The existing messages that name an id stay as they are; the refusal never holds one.deleteTelemetry,deleteManagedObjectsanddeleteManagedSystemObjectswithin a page, and the ones that callgetResultwithout a result callback);MIGRATION.mdlists which.deleteManagedObjects,deleteManagedSystemObjectanddeleteManagedSystemObjectscheck the type too, as the first statement (the real values,alpha_user,svcacctandteammember, are each one name). The existing mocked testManagedSystemObjectOps.errorWrapping.unit.test.tspassed a type with slashes (system/ldap/account), which is not a type of these functions; it now passesteammember.deleteCustomNodeadds-1to an id that does not end in it, so an id that is only refused for its end (a blank, a dot) becomes a name; the id that is sent is the one that is checked.remove*functions, the api layer, the MCP metadata and policies.The recorded answers, before any check was added
Every list that the recordings of this repository and the end-to-end recordings of frodo-cli (
test/e2e/mocksat commit6e5bcb0c5, read only) hold for a family of this change was checked against the rule; no id of any family is refused. Every DELETE request that the two sets record (252 in this repository, 317 in the CLI recordings) was checked too: the only segment that the rule would refuse is the empty id of the secret store of the type that has one store and no id (1 and 2 requests), which is not checked. Rows of a family with no recorded answer in a repository say so.nodeTypeof a node)_id, base64)Families with no recorded list at all: the log API keys. Reproduce with the script below (node 22 or later; read only):
node sweep.mjs src/test/mock-recordingsin a checkout of this repository, and for the CLI recordingsgit -C <frodo-cli> archive 6e5bcb0c5 test/e2e/mocks | tar -x -C <dir>andnode sweep.mjs <dir>.sweep.mjs
Verification
npm run check: exit 0.npx tsc --noEmit: exit 0, andtscover the changed test files (DeleteFunctions.requestPath,DeleteFunctions.bulkItems, the twoerrorWrappingtests andsrc/test): exit 0.npm run build: exit 0 andgit statusclean afterwards (src/lib/Help.tsis unchanged: the new documentation is in@throwslines).npm run test:only -- src/ops/DeleteFunctionsand-- src/ops/internal/RequestPathIdspass; the whole suite:npm test(exit 0): 474 suites passed and 1 skipped, 17723 tests passed, 10 skipped, 10 todo, 1040 snapshots passed;git statusclean afterwards (measured before the last commit, which adds three tests to the walk).deleteCertificate,deleteApplicationon IGA,deleteRequestForm,deleteLogApiKey,pruneVersionsOfSecret,deleteJourneybelow the progress indicator), and the rule of the secret store id was changed three ways (checked for every type, never checked, no type exempt): none of them survives. For the checks of the second round 17 more were run, and each fails at least one test: the filter that skips the deactivation of a refused certificate taken out, the check ofdeleteCertificatetaken out, the type checks ofdeleteManagedObjects,deleteManagedSystemObjectanddeleteManagedSystemObjectstaken out, the workflow id check taken out, moved below the first read and made unconditional, the type check ofdeleteSecretStore,deleteSecretStoreMappinganddeleteSecretStoreMappingsmade unconditional,deleteCustomNodechecking the id as given instead of the one that is sent, the not-found branch ofdeleteScriptByNametaken out, the check of a container node and the check of a listed AI agent id taken out, and the row and the exemption ofdeleteOrphanedRequestFormAssignments(removed, or both present). Four tests were added after the first run showed a check that nothing tested (the version of a node type, the opsdeleteSecret, the typed ids ofdeleteSecretStoreMappings,deleteWorkflowwith a result callback).ScriptOps.errorWrapping.unit.test.ts, the row ofdeleteScriptByName: the function now reads the script by its name and deletes it by the id that the tenant lists (it called one api function that did both, which the ops layer no longer calls; the api function itself is unchanged), so the row has two cases, the read fails and the delete fails, with the same message.ManagedSystemObjectOps.errorWrapping.unit.test.ts, the row ofdeleteManagedSystemObject: it passed the typesystem/ldap/account, which is not a type of that function and is not one name; it passesteammemberand expectsError deleting managed teammember object (u1). No recording and no snapshot is touched.Risks
undefined, an id with a slash) is now refused instead of sent. The recorded lists and DELETE requests hold no such id.deleteCertificateswith force no longer deactivates a certificate with such an id; if that certificate is the only one, the wait for the certificates to go offline ends at its own timeout, besides the refusal. No recorded list holds such an id.What the maintainer has to do
Review the rule of
assertSecretStoreId, the list of exempt functions and theMIGRATION.mdentry, which now covers every delete function.🤖 Generated with Claude Code