evsecrets
Version:
Detect environment variable secrets in your codebase before you push your code to GitHub.
103 lines (102 loc) • 3.53 kB
TypeScript
/**
* This is the primary implementation class in this library.
* Chris Joakim, 2025
*/
import { FileUtil } from "./FileUtil";
export declare class EnvScanner {
static CONFIG_FILE: string;
static VERSION: string;
fu: FileUtil;
envVarPatterns: Array<string>;
excludeFilePatterns: Array<string>;
excludeFileSuffixes: Array<string>;
allFilenames: Array<string>;
verbose: boolean;
tmpFileOutputs: boolean;
constructor();
/**
* Return the version of this npm package.
*/
static version(): string;
/**
* Write a default '.evsecrets.json' file in the current directory.
*/
init(): boolean;
/**
* Return a timestamp string, for your local timezone, in 'YYYY-MM-DD HH:MM:SS' format.
* For example: '2025-04-15 13:04:39'
*/
getFormattedTimestamp(): string;
/**
* Return an array of the secret environment variable names per your defined patterns.
* This includes the environment variable names in the .env file, if present.
*/
secretEnvVars(): Array<string>;
/**
* Display a list of your secrets defined in your specified environment variables.
*/
secrets(): void;
/**
* Scan your codebase for the secrets defined in your environment variables,
* per the configuration in .evsecrets.json or the default configuration.
* Display the matches and line numbers in the terminal output.
*/
scan(codebaseRootDir?: string, silent?: boolean): Array<string>;
/**
* Print the filteredFilenamesList on the console/terminal.
*/
files(): void;
/**
* Return a filtered list of files to scan for secrets.
*/
filteredFilenamesList(codebaseRootDir?: string): Array<string>;
/**
* Recursively walk the filesystem from the given codebaseRootDir.
* Return an unfiltered list of all of the files found; not directories.
*/
walkFs(codebaseRootDir?: string): Array<string>;
/**
* Return a boolean indicating if the given filename should be included
* in the scanning process, based on the filename patterns and filename
* suffixes in the configuration.
*/
includeThisFile(filename: string): boolean;
/**
* Return the name of the platform where this node.js process is running.
* Possible values are 'aix', 'darwin', 'freebsd', 'linux', 'openbsd', 'sunos', and 'win32'.
*/
platform(): string;
/**
* Return true if the current platform is Windows, else return false.
*/
isWindows(): boolean;
/**
* Return true if the current platform is Apple macOS, else return false.
*/
isMac(): boolean;
/**
* Return true if the current platform is Linux, else return false.
*/
isLinux(): boolean;
/**
* Return true if given command line arg (i.e. --verbose) is present, else return false.
*/
cliArgPresent(flag: string): boolean;
defaultEnvVarPatterns(): string[];
defaultExcludeFilePatterns(): string[];
defaultExcludeFileSuffixes(): string[];
/**
* This method returns the default configuration object.
* It is used by default if you don't have a ".evsecrets.json" file
* in the current directory.
*
* This object is also written to your filesystem when the 'init'
* function is executed.
*/
defaultConfig(): {
description: string;
env_var_patterns: string[];
exclude_file_patterns: string[];
exclude_file_suffixes: string[];
};
}