diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100755 index 000000000..0b3d59a18 --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,5 @@ + +#!/usr/bin/env sh +. "$(dirname -- "$0")/_/husky.sh" + +npx lint-staged diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 000000000..fa81e63de --- /dev/null +++ b/.prettierrc @@ -0,0 +1,7 @@ +{ + "semi": true, + "trailingComma": "none", + "singleQuote": true, + "printWidth": 80, + "useTabs": false +} diff --git a/README.md b/README.md index 994da9ca8..bd0442c93 100644 --- a/README.md +++ b/README.md @@ -179,6 +179,20 @@ We're currently setting the foundation and building [integrations](https://infis 🔜 Netlify (https://github.com/Infisical/infisical/issues/55) + + 🔜 Railway + + + + + 🔜 Bitbucket + + + 🔜 Supabase + + + 🔜 Serverless + @@ -261,6 +275,18 @@ We're currently setting the foundation and building [integrations](https://infis + + + + ✔️ Fiber + + + + + ✔️ Nuxt + + + @@ -285,4 +311,4 @@ Looking to report a security vulnerability? Please don't post about it in GitHub - + diff --git a/backend/.eslintrc b/backend/.eslintrc index a0c373ecb..7fe198901 100644 --- a/backend/.eslintrc +++ b/backend/.eslintrc @@ -1,18 +1,13 @@ { - "root": true, - "parser": "@typescript-eslint/parser", - "plugins": [ - "@typescript-eslint", - "prettier" - ], - "extends": [ - "eslint:recommended", - "plugin:@typescript-eslint/eslint-recommended", - "plugin:@typescript-eslint/recommended", - "prettier" - ], - "rules": { - "no-console": 2, - "prettier/prettier": 2 - } -} \ No newline at end of file + "parser": "@typescript-eslint/parser", + "plugins": ["@typescript-eslint", "prettier"], + "extends": [ + "eslint:recommended", + "plugin:@typescript-eslint/eslint-recommended", + "plugin:@typescript-eslint/recommended", + "prettier" + ], + "rules": { + "no-console": 2 + } +} diff --git a/backend/.prettierrc b/backend/.prettierrc deleted file mode 100644 index a5a98113e..000000000 --- a/backend/.prettierrc +++ /dev/null @@ -1,7 +0,0 @@ -{ - "semi": true, - "trailingComma": "none", - "singleQuote": true, - "printWidth": 80, - "useTabs": true - } diff --git a/backend/package-lock.json b/backend/package-lock.json index 19a42c3a1..c205e6483 100644 --- a/backend/package-lock.json +++ b/backend/package-lock.json @@ -50,7 +50,6 @@ "eslint": "^8.26.0", "eslint-config-prettier": "^8.5.0", "eslint-plugin-prettier": "^4.2.1", - "husky": "^8.0.1", "install": "^0.13.0", "jest": "^29.3.1", "nodemon": "^2.0.19", @@ -2594,19 +2593,6 @@ "@maxmind/geoip2-node": "^3.4.0" } }, - "node_modules/@sentry/core": { - "version": "7.17.4", - "resolved": "https://registry.npmjs.org/@sentry/core/-/core-7.17.4.tgz", - "integrity": "sha512-U3ABSJBKGK8dJ01nEG2+qNOb6Wv7U3VqoajiZxfV4lpPWNFGCoEhiTytxBlFTOCmdUH8209zSZiWJZaDLy+TSA==", - "dependencies": { - "@sentry/types": "7.17.4", - "@sentry/utils": "7.17.4", - "tslib": "^1.9.3" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/@sentry/node": { "version": "7.19.0", "resolved": "https://registry.npmjs.org/@sentry/node/-/node-7.19.0.tgz", @@ -2704,26 +2690,6 @@ "node": ">=8" } }, - "node_modules/@sentry/types": { - "version": "7.17.4", - "resolved": "https://registry.npmjs.org/@sentry/types/-/types-7.17.4.tgz", - "integrity": "sha512-QJj8vO4AtxuzQfJIzDnECSmoxwnS+WJsm1Ta2Cwdy+TUCBJyWpW7aIJJGta76zb9gNPGb3UcAbeEjhMJBJeRMQ==", - "engines": { - "node": ">=8" - } - }, - "node_modules/@sentry/utils": { - "version": "7.17.4", - "resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-7.17.4.tgz", - "integrity": "sha512-ioG0ANy8uiWzig82/e7cc+6C9UOxkyBzJDi1luoQVDH6P0/PvM8GzVU+1iUVUipf8+OL1Jh09GrWnd5wLm3XNQ==", - "dependencies": { - "@sentry/types": "7.17.4", - "tslib": "^1.9.3" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/@sinclair/typebox": { "version": "0.24.51", "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.24.51.tgz", @@ -5146,21 +5112,6 @@ "node": ">=10.17.0" } }, - "node_modules/husky": { - "version": "8.0.1", - "resolved": "https://registry.npmjs.org/husky/-/husky-8.0.1.tgz", - "integrity": "sha512-xs7/chUH/CKdOCs7Zy0Aev9e/dKOMZf3K1Az1nar3tzlv0jfqnYtu235bstsWTmXOR0EfINrPa97yy4Lz6RiKw==", - "dev": true, - "bin": { - "husky": "lib/bin.js" - }, - "engines": { - "node": ">=14" - }, - "funding": { - "url": "https://github.com/sponsors/typicode" - } - }, "node_modules/iconv-lite": { "version": "0.4.24", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", @@ -13113,16 +13064,6 @@ "@maxmind/geoip2-node": "^3.4.0" } }, - "@sentry/core": { - "version": "7.17.4", - "resolved": "https://registry.npmjs.org/@sentry/core/-/core-7.17.4.tgz", - "integrity": "sha512-U3ABSJBKGK8dJ01nEG2+qNOb6Wv7U3VqoajiZxfV4lpPWNFGCoEhiTytxBlFTOCmdUH8209zSZiWJZaDLy+TSA==", - "requires": { - "@sentry/types": "7.17.4", - "@sentry/utils": "7.17.4", - "tslib": "^1.9.3" - } - }, "@sentry/node": { "version": "7.19.0", "resolved": "https://registry.npmjs.org/@sentry/node/-/node-7.19.0.tgz", @@ -13200,20 +13141,6 @@ } } }, - "@sentry/types": { - "version": "7.17.4", - "resolved": "https://registry.npmjs.org/@sentry/types/-/types-7.17.4.tgz", - "integrity": "sha512-QJj8vO4AtxuzQfJIzDnECSmoxwnS+WJsm1Ta2Cwdy+TUCBJyWpW7aIJJGta76zb9gNPGb3UcAbeEjhMJBJeRMQ==" - }, - "@sentry/utils": { - "version": "7.17.4", - "resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-7.17.4.tgz", - "integrity": "sha512-ioG0ANy8uiWzig82/e7cc+6C9UOxkyBzJDi1luoQVDH6P0/PvM8GzVU+1iUVUipf8+OL1Jh09GrWnd5wLm3XNQ==", - "requires": { - "@sentry/types": "7.17.4", - "tslib": "^1.9.3" - } - }, "@sinclair/typebox": { "version": "0.24.51", "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.24.51.tgz", @@ -13641,8 +13568,7 @@ "version": "5.3.2", "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", - "dev": true, - "requires": {} + "dev": true }, "acorn-walk": { "version": "8.2.0", @@ -14433,8 +14359,7 @@ "version": "8.5.0", "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-8.5.0.tgz", "integrity": "sha512-obmWKLUNCnhtQRKc+tmnYuQl0pFU1ibYJQ5BGhTVB08bHe9wC8qUeG7c08dj9XX+AuPj1YSGSQIHl1pnDHZR0Q==", - "dev": true, - "requires": {} + "dev": true }, "eslint-plugin-prettier": { "version": "4.2.1", @@ -14643,8 +14568,7 @@ "express-rate-limit": { "version": "6.7.0", "resolved": "https://registry.npmjs.org/express-rate-limit/-/express-rate-limit-6.7.0.tgz", - "integrity": "sha512-vhwIdRoqcYB/72TK3tRZI+0ttS8Ytrk24GfmsxDXK9o9IhHNO5bXRiXQSExPQ4GbaE5tvIS7j1SGrxsuWs+sGA==", - "requires": {} + "integrity": "sha512-vhwIdRoqcYB/72TK3tRZI+0ttS8Ytrk24GfmsxDXK9o9IhHNO5bXRiXQSExPQ4GbaE5tvIS7j1SGrxsuWs+sGA==" }, "express-validator": { "version": "6.14.2", @@ -15034,12 +14958,6 @@ "integrity": "sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==", "dev": true }, - "husky": { - "version": "8.0.1", - "resolved": "https://registry.npmjs.org/husky/-/husky-8.0.1.tgz", - "integrity": "sha512-xs7/chUH/CKdOCs7Zy0Aev9e/dKOMZf3K1Az1nar3tzlv0jfqnYtu235bstsWTmXOR0EfINrPa97yy4Lz6RiKw==", - "dev": true - }, "iconv-lite": { "version": "0.4.24", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", @@ -15492,8 +15410,7 @@ "version": "1.2.2", "resolved": "https://registry.npmjs.org/jest-pnp-resolver/-/jest-pnp-resolver-1.2.2.tgz", "integrity": "sha512-olV41bKSMm8BdnuMsewT4jqlZ8+3TCARAXjZGT9jcoSnrfUnRCqnMoF9XEeoWjbzObpqF9dRhHQj0Xb9QdF6/w==", - "dev": true, - "requires": {} + "dev": true }, "jest-regex-util": { "version": "29.2.0", diff --git a/backend/package.json b/backend/package.json index 73cf9311f..162fb42c4 100644 --- a/backend/package.json +++ b/backend/package.json @@ -35,7 +35,8 @@ "build": "rimraf ./build && tsc && cp -R ./src/templates ./src/json ./build", "lint": "eslint . --ext .ts", "lint-and-fix": "eslint . --ext .ts --fix", - "prettier-format": "prettier --config .prettierrc 'src/**/*.ts' --write" + "prettier-format": "prettier --config .prettierrc 'src/**/*.ts' --write", + "lint-staged": "lint-staged" }, "repository": { "type": "git", @@ -63,7 +64,6 @@ "eslint": "^8.26.0", "eslint-config-prettier": "^8.5.0", "eslint-plugin-prettier": "^4.2.1", - "husky": "^8.0.1", "install": "^0.13.0", "jest": "^29.3.1", "nodemon": "^2.0.19", diff --git a/cli/packages/cmd/root.go b/cli/packages/cmd/root.go index 12e4351bb..99f7d384d 100644 --- a/cli/packages/cmd/root.go +++ b/cli/packages/cmd/root.go @@ -15,7 +15,7 @@ var rootCmd = &cobra.Command{ Short: "Infisical CLI is used to inject environment variables into any process", Long: `Infisical is a simple, end-to-end encrypted service that enables teams to sync and manage their environment variables across their development life cycle.`, CompletionOptions: cobra.CompletionOptions{DisableDefaultCmd: true}, - Version: "0.1.8", + Version: "0.1.10", } // Execute adds all child commands to the root command and sets flags appropriately. diff --git a/cli/packages/util/secrets.go b/cli/packages/util/secrets.go index d7d4cdc37..c127111b1 100644 --- a/cli/packages/util/secrets.go +++ b/cli/packages/util/secrets.go @@ -196,7 +196,6 @@ func GetSecretsFromAPIUsingInfisicalToken(infisicalToken string, envName string, } func GetAllEnvironmentVariables(projectId string, envName string) ([]models.SingleEnvironmentVariable, error) { - var envsFromApi []models.SingleEnvironmentVariable infisicalToken := os.Getenv(INFISICAL_TOKEN_NAME) if infisicalToken == "" { @@ -204,19 +203,19 @@ func GetAllEnvironmentVariables(projectId string, envName string) ([]models.Sing if err != nil { log.Info("Unexpected issue occurred while checking login status. To see more details, add flag --debug") log.Debugln(err) - return envsFromApi, err + return nil, err } if !hasUserLoggedInbefore { log.Infoln("No logged in user. To login, please run command [infisical login]") - return envsFromApi, fmt.Errorf("user not logged in") + return nil, fmt.Errorf("user not logged in") } userCreds, err := GetUserCredsFromKeyRing(loggedInUserEmail) if err != nil { log.Infoln("Unable to get user creds from key ring") log.Debug(err) - return envsFromApi, err + return nil, err } workspaceConfigs, err := GetAllWorkSpaceConfigsStartingFromCurrentPath() @@ -226,25 +225,28 @@ func GetAllEnvironmentVariables(projectId string, envName string) ([]models.Sing if len(workspaceConfigs) == 0 { log.Infoln("Your local project is not connected to a Infisical project yet. Run command [infisical init]") - return envsFromApi, fmt.Errorf("project not initialized") + return nil, fmt.Errorf("project not initialized") } - envsFromApi, err = GetSecretsFromAPIUsingCurrentLoggedInUser(envName, userCreds) + envsFromApi, err := GetSecretsFromAPIUsingCurrentLoggedInUser(envName, userCreds) if err != nil { log.Errorln("Something went wrong when pulling secrets using your logged in credentials. If the issue persists, double check your project id/try logging in again.") log.Debugln(err) - return envsFromApi, err + return nil, err } + + return envsFromApi, nil + } else { envsFromApi, err := GetSecretsFromAPIUsingInfisicalToken(infisicalToken, envName, projectId) if err != nil { log.Errorln("Something went wrong when pulling secrets using your Infisical token. Double check the token, project id or environment name (dev, prod, ect.)") log.Debugln(err) - return envsFromApi, err + return nil, err } - } - return envsFromApi, nil + return envsFromApi, nil + } } func GetWorkSpacesFromAPI(userCreds models.UserCredentials) (workspaces []models.Workspace, err error) { diff --git a/docs/cli/overview.mdx b/docs/cli/overview.mdx index 6267a66f0..144259023 100644 --- a/docs/cli/overview.mdx +++ b/docs/cli/overview.mdx @@ -1,5 +1,5 @@ --- -title: "Install" +title: 'Install' --- Prerequisite: Set up an account with [Infisical Cloud](https://app.infisical.com) or via a [self-hosted installation](/self-hosting/overview). @@ -13,11 +13,7 @@ The Infisical CLI provides a way to inject environment variables from the platfo Use [brew](https://brew.sh/) package manager ```bash - # install brew install infisical/get-cli/infisical - - # check version - infisical --version ``` ## Updates @@ -31,14 +27,13 @@ The Infisical CLI provides a way to inject environment variables from the platfo Use [Scoop](https://scoop.sh/) package manager ```bash - # install scoop bucket add org https://github.com/Infisical/scoop-infisical.git - scoop install infisical - - # check version - infisical --version ``` + ```bash + scoop install infisical + ``` + ## Updates ```bash @@ -49,33 +44,33 @@ The Infisical CLI provides a way to inject environment variables from the platfo Install prerequisite ```bash - $ sudo apk add --no-cache bash sudo + sudo apk add --no-cache bash sudo ``` Add Infisical repository ```bash - $ curl -1sLf \ + curl -1sLf \ 'https://dl.cloudsmith.io/public/infisical/infisical-cli/setup.alpine.sh' \ | sudo -E bash ``` Then install CLI ```bash - $ sudo apk update && sudo apk add infisical + sudo apk update && sudo apk add infisical ``` Add Infisical repository ```bash - $ curl -1sLf \ + curl -1sLf \ 'https://dl.cloudsmith.io/public/infisical/infisical-cli/setup.rpm.sh' \ | sudo -E bash ``` Then install CLI ```bash - $ sudo yum install infisical + sudo yum install infisical ``` @@ -83,14 +78,14 @@ The Infisical CLI provides a way to inject environment variables from the platfo Add Infisical repository ```bash - $ curl -1sLf \ + curl -1sLf \ 'https://dl.cloudsmith.io/public/infisical/infisical-cli/setup.deb.sh' \ | sudo -E bash ``` Then install CLI ```bash - $ sudo apt-get update && sudo apt-get install -y infisical + sudo apt-get update && sudo apt-get install -y infisical ``` diff --git a/docs/contributing/developing.mdx b/docs/contributing/developing.mdx index b6c25861c..64f75533f 100644 --- a/docs/contributing/developing.mdx +++ b/docs/contributing/developing.mdx @@ -16,17 +16,52 @@ cd infisical ## Set up environment variables -Tweak the `.env` according to your preferences. Refer to the available [environment variables](/self-hosting/configuration/envars). +Before running the docker-compose we have to generate the .env file with the environment variables, you can create your own file or start with the +`.env.example` as an example guide. + +Mandatory variables in the `.env` file: + +1. Keys and JWT variables + +![image](https://user-images.githubusercontent.com/118568289/206791534-9c9d1431-e83d-49c0-8a54-b373ed0df820.png) + +The `.env.example` has these variables empty, you can self generate the `JWT and ENCRYPTION_KEY` with this [32-byte random hex strings generator](https://www.browserling.com/tools/random-hex). + +For the `PRIVATE_KEY and PUBLIC_KEY` you can use the ones shown in the screenshot: -```bash -cp .env.example .env ``` +PRIVATE_KEY='oGVv5rThrpZ7WLgQW27chY1cXngr4wLQIZnGfSKgHPk=' +PUBLIC_KEY='ldr6JaC7AY+tun3omGLdE4SWpkJbtVBOI54KfUP53Xc=' +``` + +2. Mongo variables and site URL + +![image](https://user-images.githubusercontent.com/118568289/206792171-3376e3c6-c3ac-4d5d-8776-d78ee089b520.png) + +These variables are used to connect the MongoDB and set the URL for the localhost. + +For development, you can use `root` for the `MONGO_USERNAME` and `example` for the `MONGO_PASSWORD` as shown in the screenshot. + +Take into account that if you use your own `MONGO_USERNAME` and `MONGO_PASSWORD`, you also have to change the `MONGO_URL` with the form of `MONGO_USERNAME:MONGO_PASSWORD` after the `//` part of the URL. + +3. Mail SMTP service variables + +![image](https://user-images.githubusercontent.com/118568289/206792653-ba3211d1-1071-43f2-93a7-8b408bbd9e0e.png) + +These variables are needed to use the Mail SMTP service that takes care of sending the verification code when you +register in the app. + +For the `SMTP_USERNAME` variable, you will need an email with 2-steps-verification. + +For the `SMTP_PASSWORD` variable, you will need to [generate an app password](https://support.google.com/mail/answer/185833?hl=en) with the email you used in the `SMTP_USERNAME` variable. + +With this environment variables, you will be ready to run the docker-compose. ## Docker for development ```bash # build and start the services -docker-compose -f docker-compose.dev.yml up --build +docker-compose -f docker-compose.dev.yml up --build --force-recreate ``` Then browse http://localhost:8080 diff --git a/frontend/.eslintrc b/frontend/.eslintrc index b562aaa1f..d5f35096c 100644 --- a/frontend/.eslintrc +++ b/frontend/.eslintrc @@ -9,13 +9,13 @@ "plugins": ["simple-import-sort", "@typescript-eslint"], "rules": { "react-hooks/exhaustive-deps": "off", - "no-unused-vars": "off", + "no-unused-vars": "warn", + "@typescript-eslint/ban-ts-comment": "warn", "@typescript-eslint/no-unused-vars": "off", "@typescript-eslint/no-var-requires": "off", "@typescript-eslint/no-empty-function": "off", "@typescript-eslint/no-explicit-any": "off", "@typescript-eslint/no-non-null-assertion": "off", - "simple-import-sort/exports": "warn", "simple-import-sort/imports": [ "warn", diff --git a/frontend/.prettierrc b/frontend/.prettierrc deleted file mode 100644 index 222861c34..000000000 --- a/frontend/.prettierrc +++ /dev/null @@ -1,4 +0,0 @@ -{ - "tabWidth": 2, - "useTabs": false -} diff --git a/frontend/components/analytics/posthog.js b/frontend/components/analytics/posthog.js index 44ee4fdb3..8b8e88a22 100644 --- a/frontend/components/analytics/posthog.js +++ b/frontend/components/analytics/posthog.js @@ -1,16 +1,13 @@ -import posthog from "posthog-js"; +import posthog from 'posthog-js'; -import { - ENV, - POSTHOG_API_KEY, - POSTHOG_HOST, -} from "../utilities/config"; +import { ENV, POSTHOG_API_KEY, POSTHOG_HOST } from '../utilities/config'; export const initPostHog = () => { - if (typeof window !== "undefined") { - if (ENV == "production" && TELEMETRY_CAPTURING_ENABLED) { // eslint-disable-line + if (typeof window !== 'undefined') { + // eslint-disable-next-line + if (ENV == 'production' && TELEMETRY_CAPTURING_ENABLED) { posthog.init(POSTHOG_API_KEY, { - api_host: POSTHOG_HOST, + api_host: POSTHOG_HOST }); } } diff --git a/frontend/components/basic/InputField.tsx b/frontend/components/basic/InputField.tsx index 02bb8a8cc..139304ea6 100644 --- a/frontend/components/basic/InputField.tsx +++ b/frontend/components/basic/InputField.tsx @@ -21,7 +21,10 @@ interface InputFieldProps { onChangeHandler: (value: string) => void; } -const InputField = (props: InputFieldProps) => { +const InputField = ( + props: InputFieldProps & + Pick +) => { const [passwordVisible, setPasswordVisible] = useState(false); const router = useRouter(); @@ -43,6 +46,8 @@ const InputField = (props: InputFieldProps) => { className="bg-bunker-800 text-gray-400 border border-gray-600 rounded-md text-md p-2 w-full min-w-16 outline-none" name={props.name} readOnly + autoComplete={props.autoComplete} + id={props.id} /> ); @@ -88,6 +93,8 @@ const InputField = (props: InputFieldProps) => { } relative peer bg-bunker-800 rounded-md text-gray-400 text-md p-2 w-full min-w-16 outline-none focus:ring-4 duration-200`} name={props.name} spellCheck="false" + autoComplete={props.autoComplete} + id={props.id} /> {props.label?.includes("Password") && (