mirror of
https://github.com/AikidoSec/safe-chain.git
synced 2026-05-26 12:10:49 +00:00
Add file-based logging
This commit is contained in:
parent
0c8de1e606
commit
c4af781a7f
16 changed files with 1604 additions and 5 deletions
|
|
@ -12,6 +12,9 @@ import { getSafeChainBaseDir } from "./safeChainDir.js";
|
|||
* @property {unknown | Number} scanTimeout
|
||||
* @property {unknown | Number} minimumPackageAgeHours
|
||||
* @property {unknown | string} malwareListBaseUrl
|
||||
* @property {unknown | string} logFile
|
||||
* @property {unknown | string} logFileFormat
|
||||
* @property {unknown | string} logFileVerbosity
|
||||
* @property {unknown | SafeChainRegistryConfiguration} npm
|
||||
* @property {unknown | SafeChainRegistryConfiguration} pip
|
||||
*
|
||||
|
|
@ -98,6 +101,42 @@ export function getMalwareListBaseUrl() {
|
|||
return undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the log file path from the config file
|
||||
* @returns {string | undefined}
|
||||
*/
|
||||
export function getLogFile() {
|
||||
const config = readConfigFile();
|
||||
if (config.logFile && typeof config.logFile === "string") {
|
||||
return config.logFile;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the log file format from the config file
|
||||
* @returns {string | undefined}
|
||||
*/
|
||||
export function getLogFileFormat() {
|
||||
const config = readConfigFile();
|
||||
if (config.logFileFormat && typeof config.logFileFormat === "string") {
|
||||
return config.logFileFormat;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the log file verbosity from the config file
|
||||
* @returns {string | undefined}
|
||||
*/
|
||||
export function getLogFileVerbosity() {
|
||||
const config = readConfigFile();
|
||||
if (config.logFileVerbosity && typeof config.logFileVerbosity === "string") {
|
||||
return config.logFileVerbosity;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the custom npm registries from the config file (format parsing only, no validation)
|
||||
* @returns {string[]}
|
||||
|
|
@ -229,6 +268,9 @@ function readConfigFile() {
|
|||
scanTimeout: undefined,
|
||||
minimumPackageAgeHours: undefined,
|
||||
malwareListBaseUrl: undefined,
|
||||
logFile: undefined,
|
||||
logFileFormat: undefined,
|
||||
logFileVerbosity: undefined,
|
||||
npm: {
|
||||
customRegistries: undefined,
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue