Conversation
Remove instance tokens from fetchInstances responses unless AUTHENTICATION_EXPOSE_IN_FETCH_INSTANCES is explicitly enabled.
Contributor
Reviewer's guide (collapsed on small PRs)Reviewer's GuideUpdates instance fetching to hide instance tokens whenever AUTHENTICATION_EXPOSE_IN_FETCH_INSTANCES is disabled, while preserving the existing response when explicitly enabled and avoiding mutation of source records. Sequence diagram for sanitized instance fetchingsequenceDiagram
participant Client
participant InstanceController
participant PrismaRepository
participant WAMonitor
Client->>InstanceController: fetchInstances(instanceName, instanceId, number, key)
InstanceController->>InstanceController: get AUTHENTICATION settings
alt Invalid API key
InstanceController->>PrismaRepository: findMany(instance names)
PrismaRepository-->>InstanceController: authorized instances
InstanceController->>WAMonitor: instanceInfo(names)
WAMonitor-->>InstanceController: instance records
else Lookup by instanceId or number
InstanceController->>WAMonitor: instanceInfoById(instanceId, number)
WAMonitor-->>InstanceController: instance records
else Unfiltered or name-filtered lookup
InstanceController->>WAMonitor: instanceInfo(instanceNames)
WAMonitor-->>InstanceController: instance records
end
alt EXPOSE_IN_FETCH_INSTANCES enabled
InstanceController-->>Client: records including token
else Exposure disabled
InstanceController->>InstanceController: hideTokens(instances)
InstanceController-->>Client: copied records without token
end
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Contributor
There was a problem hiding this comment.
Hey - I've reviewed your changes and they look great!
Sourcery assessment
Needs a human reviewer. This changes whether authenticated callers receive instance tokens, which are credentials and could affect access to instances. Reverting restores the previous response behavior, but any tokens exposed during an incorrect configuration or implementation could be used before the revert.
This branch has not been deployed
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.
📋 Description
Prevent
GET /instance/fetchInstancesfrom returning instance tokens whenAUTHENTICATION_EXPOSE_IN_FETCH_INSTANCES=false.The response is sanitized consistently for:
When exposure is explicitly enabled, the existing response remains unchanged.
🔗 Related Issue
Closes #2677
🧪 Type of Change
🧪 Testing
npx eslint src/api/controllers/instance.controller.tsnpx tsc --noEmitnpm run build✅ Checklist
📝 Additional Notes
The change only removes the
tokenproperty from returned copies of instance records; it does not mutate the records returned by the monitoring service.Summary by Sourcery
Hide instance tokens from fetch responses unless token exposure is explicitly enabled.
Bug Fixes:
Enhancements: