From 04c74293ed97e67fa67377f1405d21ddd01ef7da Mon Sep 17 00:00:00 2001 From: Akhil Mohan Date: Sat, 30 Sep 2023 23:47:38 +0530 Subject: [PATCH 1/6] fix: resolved dashboard showing text folderName in nesting folders --- frontend/src/components/navigation/NavHeader.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/components/navigation/NavHeader.tsx b/frontend/src/components/navigation/NavHeader.tsx index f783cdb86..866010c21 100644 --- a/frontend/src/components/navigation/NavHeader.tsx +++ b/frontend/src/components/navigation/NavHeader.tsx @@ -144,7 +144,7 @@ export default function NavHeader({ href={{ pathname: "/project/[id]/secrets/[env]", query }} > - folderName + {folderName} )} From 3456dfbd86a5771b0e840b2d9628809e70a9a7c5 Mon Sep 17 00:00:00 2001 From: Maidul Islam Date: Mon, 2 Oct 2023 11:40:00 -0700 Subject: [PATCH 2/6] handle siginit and sigterm --- backend/src/index.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/backend/src/index.ts b/backend/src/index.ts index 2a5159738..994e24cc1 100644 --- a/backend/src/index.ts +++ b/backend/src/index.ts @@ -225,8 +225,19 @@ const main = async () => { server.on("close", async () => { await DatabaseService.closeDatabase(); - syncSecretsToThirdPartyServices.close(); - githubPushEventSecretScan.close(); + // TODO: prevent queue from trying to reconnect with redis after .close + syncSecretsToThirdPartyServices.close() + githubPushEventSecretScan.close() + }); + + process.on("SIGINT", function () { + server.close(); + process.exit(0); + }); + + process.on("SIGTERM", function () { + server.close(); + process.exit(0); }); return server; From bd8c17d720f7d8cef8de213b5373652c07c4a62a Mon Sep 17 00:00:00 2001 From: Maidul Islam Date: Mon, 2 Oct 2023 18:58:38 -0400 Subject: [PATCH 3/6] resolve merge conflict --- backend/src/index.ts | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/backend/src/index.ts b/backend/src/index.ts index 994e24cc1..3d6dfaaa9 100644 --- a/backend/src/index.ts +++ b/backend/src/index.ts @@ -223,21 +223,25 @@ const main = async () => { // await createTestUserForDevelopment(); setUpHealthEndpoint(server); - server.on("close", async () => { + + const serverCleanup = async () => { await DatabaseService.closeDatabase(); - // TODO: prevent queue from trying to reconnect with redis after .close - syncSecretsToThirdPartyServices.close() - githubPushEventSecretScan.close() - }); + syncSecretsToThirdPartyServices.close(); + githubPushEventSecretScan.close(); + + process.exit(0); + } process.on("SIGINT", function () { - server.close(); - process.exit(0); + server.close(async () => { + await serverCleanup() + }); }); process.on("SIGTERM", function () { - server.close(); - process.exit(0); + server.close(async () => { + await serverCleanup() + }); }); return server; From f3908e6b2add76a07b9e0412450eeb90513da175 Mon Sep 17 00:00:00 2001 From: Akhil Mohan Date: Tue, 3 Oct 2023 20:14:43 +0530 Subject: [PATCH 4/6] fix: resolved permission check on imported secrets when using service token --- backend/src/controllers/v3/secretsController.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/backend/src/controllers/v3/secretsController.ts b/backend/src/controllers/v3/secretsController.ts index 451de1294..b388f8305 100644 --- a/backend/src/controllers/v3/secretsController.ts +++ b/backend/src/controllers/v3/secretsController.ts @@ -3,7 +3,7 @@ import { Types } from "mongoose"; import { EventService, SecretService } from "../../services"; import { eventPushSecrets } from "../../events"; import { BotService } from "../../services"; -import { containsGlobPatterns, isValidScope, repackageSecretToRaw } from "../../helpers/secrets"; +import { containsGlobPatterns, repackageSecretToRaw } from "../../helpers/secrets"; import { encryptSymmetric128BitHexKeyUTF8 } from "../../utils/crypto"; import { getAllImportedSecrets } from "../../services/SecretImportService"; import { Folder, IServiceTokenData } from "../../models"; @@ -81,8 +81,7 @@ export const getSecretsRaw = async (req: Request, res: Response) => { secretPath, requiredPermissions: [PERMISSION_READ_SECRETS] }); - permissionCheckFn = (env: string, secPath: string) => - isValidScope(req.authData.authPayload as IServiceTokenData, env, secPath); + permissionCheckFn = () => true; } const secrets = await SecretService.getSecrets({ @@ -447,8 +446,7 @@ export const getSecrets = async (req: Request, res: Response) => { secretPath, requiredPermissions: [PERMISSION_READ_SECRETS] }); - permissionCheckFn = (env: string, secPath: string) => - isValidScope(req.authData.authPayload as IServiceTokenData, env, secPath); + permissionCheckFn = () => true; } const secrets = await SecretService.getSecrets({ From 501d940558b11e2d3fe18c3b3d26692f2f3f2fdb Mon Sep 17 00:00:00 2001 From: Maidul Islam Date: Tue, 3 Oct 2023 20:00:40 -0400 Subject: [PATCH 5/6] add Gradle docs --- docs/integrations/frameworks/gradle.mdx | 91 +++++++++++++++++++++++++ docs/mint.json | 6 ++ 2 files changed, 97 insertions(+) create mode 100644 docs/integrations/frameworks/gradle.mdx diff --git a/docs/integrations/frameworks/gradle.mdx b/docs/integrations/frameworks/gradle.mdx new file mode 100644 index 000000000..5005433d0 --- /dev/null +++ b/docs/integrations/frameworks/gradle.mdx @@ -0,0 +1,91 @@ +--- +title: "Gradle" +description: "How to use Infisical to inject environment variables with Gradle" +--- + +# Using Infisical with Gradle + +By integrating [Infisical CLI](../../cli/overview) with Gradle, you can configure your builds and scripts to different environments, CI/CD pipelines, and more without explicitly setting variables in the command line. + +This documentation provides an overview of how to use Infisical with [Gradle](https://gradle.org/). + +## Basic Usage + +To run a Gradle task with Infisical, you can use the `run` command. The basic structure is: + +``` +infisical run -- [Your command here] +``` + +For example, to run the `generateFile` task in Gradle: + +```groovy build.gradle +task generateFile { + doLast { + String content = System.getenv('ENV_NAME_FROM_INFISICAL') ?: 'Default Content' + file('output.txt').text = content + println "Generated output.txt with content: $content" + } +} +``` + +``` +infisical run -- gradle generateFile +``` + +With this command, Infisical will automatically inject the environment variables associated with the current Infisical project into the Gradle process. +Your Gradle script can then access these variables using `System.getenv('VARIABLE_NAME')`. + +## More Examples + +### 1. Building a Project with a Specific Profile + +Assuming you have different build profiles (e.g., 'development', 'production'), you can use Infisical to switch between them: + +``` +infisical run -- gradle build +``` + +Inside your `build.gradle`, you might have: + +```groovy build.gradle +if (System.getenv('PROFILE') == 'production') { + // production-specific configurations +} +``` + +### 2. Running Tests with Different Database Configurations + +If you want to run tests against different database configurations: + +``` +infisical run -- gradle test +``` + +Your test configuration in `build.gradle` can then adjust the database URL accordingly: + +```groovy build.gradle +test { + systemProperty 'db.url', System.getenv('DB_URL') +} +``` + +### 3. Generating Artifacts with Versioning + +For automated CI/CD pipelines, you might want to inject a build number or version: + +``` +infisical run -- gradle assemble +``` + +And in `build.gradle`: + +```groovy build.gradle +version = System.getenv('BUILD_NUMBER') ?: '1.0.0-SNAPSHOT' +``` + +## Advantages of Using Infisical with Gradle + +1. **Flexibility**: Easily adapt your Gradle builds to different environments without modifying the build scripts or setting environment variables manually. +2. **Reproducibility**: Ensure consistent builds by leveraging the environment variables from the related Infisical project. +3. **Security**: Protect sensitive information by using Infisical's secrets management without exposing them in scripts or logs. diff --git a/docs/mint.json b/docs/mint.json index 975687508..f89db202e 100644 --- a/docs/mint.json +++ b/docs/mint.json @@ -276,6 +276,12 @@ "integrations/platforms/pm2" ] }, + { + "group": "Build Tool Integrations", + "pages": [ + "integrations/frameworks/gradle" + ] + }, { "group": "Overview", "pages": ["sdks/overview"] From 49098b7693fca2710c1815e61658f45affb400a1 Mon Sep 17 00:00:00 2001 From: Maidul Islam Date: Tue, 3 Oct 2023 20:12:03 -0400 Subject: [PATCH 6/6] update folder name of build tool integrations --- docs/integrations/{frameworks => build-tools}/gradle.mdx | 0 docs/mint.json | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename docs/integrations/{frameworks => build-tools}/gradle.mdx (100%) diff --git a/docs/integrations/frameworks/gradle.mdx b/docs/integrations/build-tools/gradle.mdx similarity index 100% rename from docs/integrations/frameworks/gradle.mdx rename to docs/integrations/build-tools/gradle.mdx diff --git a/docs/mint.json b/docs/mint.json index f89db202e..c6c0eef3d 100644 --- a/docs/mint.json +++ b/docs/mint.json @@ -279,7 +279,7 @@ { "group": "Build Tool Integrations", "pages": [ - "integrations/frameworks/gradle" + "integrations/build-tools/gradle" ] }, {