feat(servicenow): register action for incident listing#8540
feat(servicenow): register action for incident listing#8540drodil wants to merge 1 commit intobackstage:mainfrom
Conversation
Changed Packages
|
7d19608 to
c920762
Compare
There was a problem hiding this comment.
Hi @drodil , thanks for the PR 👍
I have two safety concerns:
-
Unscoped listing: When no entity name is provided, the action can query ServiceNow broadly using the integration account, which is a larger exposure than the authenticated
/incidentsroute. -
Validation gap: The REST handler uses
validateIncidentQueryParams(allowlistedstate/priority/orderBy, etc.), but the action passes those fields straight intofetchIncidents. I’d like the same rules on both paths so we don’t widen risk (e.g. encoded-query edge cases).
Can we make registering this action opt-in (e.g. a servicenow.actions.enabled config flag, default off for the first release) so teams only enable it when they’re comfortable with Actions calling ServiceNow?
Longer term, if we add more ServiceNow actions, we could split them into a small dedicated backend module (similar to scaffolder-backend-module-servicenow) so adopters can opt in at the package level too. Happy to open a follow-up issue if that direction makes sense.
|
@ciiay good points, should we force the entity selection in the listing? The validation gap can also be fixed by using the zod enumeration for those fields. All actions already require opt-in via config |
c920762 to
22528d8
Compare
… listing Signed-off-by: Hellgren Heikki <heikki.hellgren@op.fi>
22528d8 to
12a3740
Compare
ciiay
left a comment
There was a problem hiding this comment.
Thanks for the quick follow-up and the changes 🤝 This lines up well with my earlier comment.
On your points
- Forcing entity selection: Agreed. Requiring
name(and resolving via the catalog withcredentials) is the right tradeoff and matches the “scoped listing” story. - Validation: Using allowlists +
IN…for state/priority andIncidentFieldEnumfororderByis a solid fix and much closer to the REST path.- Optional polish: mirror the REST
userEmailshape check for parity, and consider sharing the allowed state/priority lists withvalidator.tsso they can’t drift.
- Optional polish: mirror the REST
- Opt-in via
actions.pluginSources: Good point. A short note in the plugin docs or changelog that enabling this backend as an action source exposesservicenow:list-incidentswould still help operators. - Keeping actions in this backend package: Agreed. Splitting isn’t necessary here given the existing wiring.
One thing to double-check in code (not introduced by the action alone):
The action now always passes u_backstage_entity_id into fetchIncidents, but DefaultServiceNowClient still doesn’t append u_backstage_entity_id to sysparm_query (it’s predefined so it’s skipped in the generic loop, and there’s no explicit branch). Worth confirming end-to-end against a real instance; if filtering isn’t applied, adding an explicit u_backstage_entity_id=… fragment in the client would make the forced-entity behavior actually hold in ServiceNow.
| const ALLOWED_STATES = ['1', '2', '3', '6', '7', '8'] as const; | ||
| const ALLOWED_PRIORITIES = ['1', '2', '3', '4', '5'] as const; |
There was a problem hiding this comment.
These are duplicated to consts in validator.ts. We can extract these to reusable consts to avoid redundant.
Hey, I just made a Pull Request!
Add action to servicenow plugin for listing incidents.
✔️ Checklist
Signed-off-byline in the message. (more info)