first commit
This commit is contained in:
commit
7988853b57
43 changed files with 8415 additions and 0 deletions
83
src/config/appConfig.js
Normal file
83
src/config/appConfig.js
Normal file
|
@ -0,0 +1,83 @@
|
|||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const yaml = require('js-yaml');
|
||||
|
||||
// Load YAML configuration file
|
||||
let yamlConfig = {};
|
||||
try {
|
||||
const configPath = path.join(__dirname, '..', '..', 'fylgja.yml');
|
||||
const fileContents = fs.readFileSync(configPath, 'utf8');
|
||||
yamlConfig = yaml.load(fileContents);
|
||||
console.log('Successfully loaded fylgja.yml configuration');
|
||||
} catch (error) {
|
||||
console.error(`Error loading fylgja.yml: ${error.message}`);
|
||||
console.log('Using default configuration values');
|
||||
// Default values will be used if file cannot be loaded
|
||||
}
|
||||
|
||||
// Base directory for resolving relative paths from config
|
||||
const baseDir = path.join(__dirname, '..', '..');
|
||||
|
||||
// Configuration paths
|
||||
module.exports = {
|
||||
|
||||
SLACK_CONFIG: {
|
||||
botToken: yamlConfig?.slack?.bot_token || process.env.SLACK_BOT_TOKEN,
|
||||
signingSecret: yamlConfig?.slack?.signing_secret || process.env.SLACK_SIGNING_SECRET
|
||||
},
|
||||
|
||||
// Server configuration from YAML (with fallback to env vars)
|
||||
SERVER_CONFIG: {
|
||||
port: parseInt(yamlConfig?.server?.port || process.env.PORT || 3000)
|
||||
},
|
||||
|
||||
// Path configurations
|
||||
SIGMA_REPO_DIR: yamlConfig?.paths?.sigma_repo_dir
|
||||
? path.resolve(baseDir, yamlConfig.paths.sigma_repo_dir)
|
||||
: path.join(baseDir, 'sigma-repo'),
|
||||
|
||||
DB_PATH: yamlConfig?.paths?.db_path
|
||||
? path.resolve(baseDir, yamlConfig.paths.db_path)
|
||||
: path.resolve(baseDir, 'sigma.db'),
|
||||
|
||||
// Load SIGMA_CLI_PATH from YAML, env, or use default path
|
||||
SIGMA_CLI_PATH: yamlConfig?.sigma?.['sigma-cli']?.path
|
||||
? path.resolve(baseDir, yamlConfig.sigma['sigma-cli'].path)
|
||||
: path.join(process.env.VIRTUAL_ENV || './.venv', 'bin', 'sigma'),
|
||||
|
||||
// Sigma CLI configuration from YAML
|
||||
SIGMA_CLI_CONFIG: {
|
||||
backend: yamlConfig?.sigma?.['sigma-cli']?.backend || "lucene",
|
||||
target: yamlConfig?.sigma?.['sigma-cli']?.target || "ecs_windows",
|
||||
format: yamlConfig?.sigma?.['sigma-cli']?.format || "siem_rule_ndjson"
|
||||
},
|
||||
|
||||
// Sigma Repository configuration from YAML
|
||||
SIGMA_REPO_CONFIG: {
|
||||
url: yamlConfig?.sigma?.repo?.url || "https://github.com/SigmaHQ/sigma.git",
|
||||
branch: yamlConfig?.sigma?.repo?.branch || "main"
|
||||
},
|
||||
|
||||
// Elasticsearch configuration from YAML
|
||||
ELASTICSEARCH_CONFIG: {
|
||||
apiEndpoint: yamlConfig?.elastic?.['api-endpoint'] ||
|
||||
"http://localhost:5601/api/detection_engine/rules",
|
||||
credentials: yamlConfig?.elastic?.['elastic-authentication-credentials'] ||
|
||||
"elastic:changeme"
|
||||
},
|
||||
|
||||
// Logging configuration from YAML
|
||||
LOGGING_CONFIG: {
|
||||
level: yamlConfig?.logging?.level || "info",
|
||||
file: yamlConfig?.logging?.file || "./logs/fylgja.log"
|
||||
},
|
||||
|
||||
// Default configuration (fallback)
|
||||
DEFAULT_CONFIG: {
|
||||
siem: 'elasticsearch',
|
||||
lang: 'lucene',
|
||||
output: 'ndjson',
|
||||
repoUrl: yamlConfig?.sigma?.repo?.url || "https://github.com/SigmaHQ/sigma.git",
|
||||
repoBranch: yamlConfig?.sigma?.repo?.branch || "main"
|
||||
}
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue