Skip to content

feat(agent): get secrets by project slug#150

Merged
varonix0 merged 1 commit intomainfrom
daniel/get-secrets-by-project-slug
Mar 17, 2026
Merged

feat(agent): get secrets by project slug#150
varonix0 merged 1 commit intomainfrom
daniel/get-secrets-by-project-slug

Conversation

@varonix0
Copy link
Member

Description 📣

Added new templating function to allow fetching secrets by project slug rather than project ID.

Type ✨

  • Bug fix
  • New feature
  • Improvement
  • Breaking change
  • Documentation

@varonix0 varonix0 self-assigned this Mar 16, 2026
@varonix0 varonix0 requested a review from victorvhs017 March 16, 2026 23:25
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 16, 2026

Greptile Summary

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.

Last reviewed commit: 62d743d

Copy link
Contributor

@victorvhs017 victorvhs017 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested, working great!

@varonix0 varonix0 merged commit ef5c77e into main Mar 17, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants