- Invoke-WebRequest link
- For secrets stored in source code
- For secrets stored in configuration files
Install Locker CLI
- Windows
- Linux
- macOS (arm)
- macOS (x64)
Detect Secrets in your project
Use thescan command as follows:

Change to a secure way of storing Secrets
With the findings from the scan, you will need to change how they are stored more securely instead of hardcoding. Initialize a project on Locker Secrets- Create a Locker Secrets account here if you don’t have one yet.
- Create a new project, corresponding to the project that contains your secrets.
- Create an Access Key in the Project. This is the key pair you will use for the Locker SDK in the following steps.
For secrets stored in source code
With a small number of secrets stored in source code, you can manually update them by following these steps:- Add the corresponding hardcoded secrets to the Locker Secrets Project you just created through the web interface.
- Install the Secrets SDK corresponding to the language you are using here.
- Use the Access Key and Secret Access Key pair above to initialize in the SDK Config object.
- Manually find the location where your secret is hardcoded, then replace it by using the SDK to call the corresponding secret variable that was previously stored.
The automatic secrets update feature is being developed and will be available in upcoming versions.
settings.py file with hardcoded values as follows:
requirements.txt
- Linux/macOS
- Windows (Powershell)
- Windows (Command Prompt)
secret_management.py
settings.py
scan fix option. This option will upload all of your secrets to the corresponding Locker project, and automatically replace the secrets in the source code by using the SDK:
- Store the Locker Access Key pair using environment variables (same as above).
- Use the
scan fixcommand:
- Review your source code to ensure the secrets are called and used for their intended purpose.
Currently, the scan fix option is only supported for the Python language. Other languages will be added in the near future.
locker scan fix --source . --language python command, the secrets will be automatically uploaded to the project with incrementally named keys like SECRET1, SECRET2 and a Locker SDK instance will be initialized:
secret_manager.py
settings.py
For secrets stored in environment variable files
- Check whether the environment variable file is necessary for the project. If not, proceed to delete this environment variable file.
- If your project needs the secrets in this environment variable file, configure Locker with the Access Key pair you created using the command:
- Save the secret to the Locker Secret Vault:
- Use the
locker secret runcommand to run your project with the stored secrets:
locker run command will inject the secrets from a specified environment as environment variables into your program’s run command.
- Delete the secrets stored in your environment variable file.
For secrets stored in configuration files
- Configure Locker CLI with the Access Key and Secret Key pair you created earlier:
- Based on the scan results, identify the configuration file containing your secrets, then use Locker CLI to import these secrets to the project:
- If your program uses secrets stored in the configuration file, replace the part of the source code that uses this config file with the Locker SDK.