You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR adds a new listSecretsByProjectSlug template function to the Infisical agent, allowing secrets to be fetched by project slug rather than project ID. It also refactors the three Process*Template functions to share a common newTemplateFunctions helper, reducing duplication, and adds a camelCase dynamicSecret alias alongside the existing dynamic_secret (kept as deprecated).
Key findings:
Uncached slug resolution (logic):secretTemplateByProjectSlugFunction creates a new HTTP client and makes an extra GET /v1/projects/slug/{slug} call on every template evaluation. Since slug→ID is a static mapping, this doubles API calls on every agent rotation cycle. A simple closure-level cache (map + mutex) would eliminate the redundant requests.
URL path injection (logic): The projectSlug value is interpolated directly into the URL path in api.CallGetProjectBySlug without url.PathEscape. A slug containing / or .. segments could manipulate the API endpoint being reached. This is a pre-existing issue in api.go but is newly exposed through the template function introduced here.
Documentation (style): No documentation for the new listSecretsByProjectSlug or dynamicSecret template functions exists in this repo; a companion docs PR may be needed.
Confidence Score: 3/5
PR introduces a functional improvement but has a performance issue and a URL path injection risk that should be addressed before merging.
The core feature logic is sound and the refactoring reduces duplication. However, the slug-to-ID lookup on every template evaluation is a real performance concern for frequently-rotating agents, and the lack of URL path encoding on the slug creates a path manipulation risk (even if the attack surface is limited to trusted config authors).
packages/cmd/agent.go (new secretTemplateByProjectSlugFunction) and packages/api/api.go (CallGetProjectBySlug URL construction)
Important Files Changed
Filename
Overview
packages/cmd/agent.go
Adds listSecretsByProjectSlug template function and refactors template function map into a shared newTemplateFunctions helper. New function makes an uncached extra API call per invocation to resolve slug→ID, and the slug is inserted into the URL path without encoding.
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
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 📣
Added new templating function to allow fetching secrets by project slug rather than project ID.
Type ✨