-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat: secret version value redaction #5392
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
7e2ac59
feat: redact secret version values
varonix0 065c05b
fix: update secret versions correctly on move
varonix0 cf74998
Update SecretVersionDiffView.tsx
varonix0 c4a12c9
fix: nits
varonix0 df7a34c
fixes
varonix0 5826c00
fix frontend lint
varonix0 d6fe231
Update 20260205204147_redact-secret-version-values.ts
varonix0 a338254
Merge branch 'main' into daniel/secret-version-value-redaction
varonix0 9be9db2
Update license-fns.ts
varonix0 410edb5
fix: nit and type check
varonix0 9d051ff
Update secret-versions-v2.ts
varonix0 db3cbd3
Update secret-v2-bridge-service.ts
varonix0 b8fd8d5
Merge branch 'main' into daniel/secret-version-value-redaction
varonix0 3b5f860
requested changes
varonix0 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
backend/src/db/migrations/20260205204147_redact-secret-version-values.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| import { Knex } from "knex"; | ||
|
|
||
varonix0 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| import { TableName } from "../schemas"; | ||
varonix0 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
varonix0 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| export async function up(knex: Knex): Promise<void> { | ||
carlosmonastyrski marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| const hasIsRedactedColumn = await knex.schema.hasColumn(TableName.SecretVersionV2, "isRedacted"); | ||
carlosmonastyrski marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| const hasRedactedAtColumn = await knex.schema.hasColumn(TableName.SecretVersionV2, "redactedAt"); | ||
| const hasRedactedByUserColumn = await knex.schema.hasColumn(TableName.SecretVersionV2, "redactedByUserId"); | ||
| const hasParentVersionIdColumn = await knex.schema.hasColumn(TableName.SecretVersionV2, "parentVersionId"); | ||
|
|
||
| const missingColumns = | ||
| !hasIsRedactedColumn || !hasRedactedAtColumn || !hasRedactedByUserColumn || !hasParentVersionIdColumn; | ||
|
|
||
| if (missingColumns) { | ||
| await knex.schema.alterTable(TableName.SecretVersionV2, (table) => { | ||
| if (!hasParentVersionIdColumn) { | ||
| table.uuid("parentVersionId").references("id").inTable(TableName.SecretVersionV2).onDelete("SET NULL"); | ||
| table.index("parentVersionId"); | ||
| } | ||
|
|
||
| if (!hasIsRedactedColumn) table.boolean("isRedacted").defaultTo(false).notNullable(); | ||
| if (!hasRedactedAtColumn) table.timestamp("redactedAt").nullable(); | ||
| if (!hasRedactedByUserColumn) | ||
| table.uuid("redactedByUserId").references("id").inTable(TableName.Users).onDelete("SET NULL"); | ||
| }); | ||
| } | ||
| } | ||
|
|
||
| export async function down(knex: Knex): Promise<void> { | ||
| const hasIsRedactedColumn = await knex.schema.hasColumn(TableName.SecretVersionV2, "isRedacted"); | ||
| const hasRedactedAtColumn = await knex.schema.hasColumn(TableName.SecretVersionV2, "redactedAt"); | ||
| const hasRedactedByUserColumn = await knex.schema.hasColumn(TableName.SecretVersionV2, "redactedByUserId"); | ||
| const hasParentVersionIdColumn = await knex.schema.hasColumn(TableName.SecretVersionV2, "parentVersionId"); | ||
| const hasColumns = hasIsRedactedColumn || hasRedactedAtColumn || hasRedactedByUserColumn || hasParentVersionIdColumn; | ||
|
|
||
| if (hasColumns) { | ||
| await knex.schema.alterTable(TableName.SecretVersionV2, (table) => { | ||
| if (hasParentVersionIdColumn) { | ||
| table.dropIndex("parentVersionId"); | ||
| table.dropColumn("parentVersionId"); | ||
| } | ||
| if (hasIsRedactedColumn) table.dropColumn("isRedacted"); | ||
| if (hasRedactedAtColumn) table.dropColumn("redactedAt"); | ||
| if (hasRedactedByUserColumn) table.dropColumn("redactedByUserId"); | ||
| }); | ||
| } | ||
| } | ||
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| import { z } from "zod"; | ||
|
|
||
| import { SecretVersionsV2Schema } from "@app/db/schemas"; | ||
| import { EventType } from "@app/ee/services/audit-log/audit-log-types"; | ||
| import { writeLimit } from "@app/server/config/rateLimiter"; | ||
| import { verifyAuth } from "@app/server/plugins/auth/verify-auth"; | ||
| import { AuthMode } from "@app/services/auth/auth-type"; | ||
|
|
||
| export const registerSecretVersionRouter = async (server: FastifyZodProvider) => { | ||
| server.route({ | ||
| method: "DELETE", | ||
| url: "/:versionId/redact-value", | ||
| config: { | ||
| rateLimit: writeLimit | ||
| }, | ||
| schema: { | ||
| params: z.object({ | ||
| versionId: z.string() | ||
| }), | ||
| response: { | ||
| 200: z.object({ | ||
| secretVersion: SecretVersionsV2Schema.omit({ encryptedValue: true, encryptedComment: true }) | ||
| }) | ||
| } | ||
| }, | ||
| onRequest: verifyAuth([AuthMode.JWT]), | ||
varonix0 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| handler: async (req) => { | ||
| const { secretVersion, projectId, environment, secretPath, secretKey, secretId } = | ||
| await server.services.secret.redactSecretVersionValue({ | ||
| actor: req.permission.type, | ||
| actorId: req.permission.id, | ||
| actorAuthMethod: req.permission.authMethod, | ||
| actorOrgId: req.permission.orgId, | ||
| versionId: req.params.versionId | ||
| }); | ||
|
|
||
| await server.services.auditLog.createAuditLog({ | ||
| projectId, | ||
| ...req.auditLogInfo, | ||
| event: { | ||
| type: EventType.REDACT_SECRET_VERSION_VALUE, | ||
| metadata: { | ||
| environment, | ||
| secretPath, | ||
| secretId, | ||
| secretKey, | ||
| secretVersionId: secretVersion.id, | ||
| secretVersion: secretVersion.version | ||
| } | ||
| } | ||
| }); | ||
|
|
||
| return { secretVersion }; | ||
| } | ||
| }); | ||
| }; | ||
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
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
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
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.