guardian-risk-logger 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +0 -2
- package/dist/index.js +0 -2
- package/package.json +8 -3
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
package/dist/index.cjs
CHANGED
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "guardian-risk-logger",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Audit logging plugin for guardian-risk — logs reports and matched rules",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -20,7 +20,10 @@
|
|
|
20
20
|
},
|
|
21
21
|
"sideEffects": false,
|
|
22
22
|
"files": [
|
|
23
|
-
"dist",
|
|
23
|
+
"dist/index.js",
|
|
24
|
+
"dist/index.cjs",
|
|
25
|
+
"dist/index.d.ts",
|
|
26
|
+
"dist/index.d.cts",
|
|
24
27
|
"README.md",
|
|
25
28
|
"LICENSE"
|
|
26
29
|
],
|
|
@@ -36,6 +39,7 @@
|
|
|
36
39
|
"risk",
|
|
37
40
|
"security"
|
|
38
41
|
],
|
|
42
|
+
"author": "himanshuusinghh",
|
|
39
43
|
"license": "MIT",
|
|
40
44
|
"repository": {
|
|
41
45
|
"type": "git",
|
|
@@ -46,6 +50,7 @@
|
|
|
46
50
|
"bugs": {
|
|
47
51
|
"url": "https://github.com/himanshu6306singh/guardian-risk/issues"
|
|
48
52
|
},
|
|
53
|
+
"security": "https://github.com/himanshu6306singh/guardian-risk/security/policy",
|
|
49
54
|
"publishConfig": {
|
|
50
55
|
"access": "public"
|
|
51
56
|
},
|
|
@@ -55,7 +60,7 @@
|
|
|
55
60
|
"devDependencies": {
|
|
56
61
|
"tsup": "^8.3.5",
|
|
57
62
|
"typescript": "^5.7.2",
|
|
58
|
-
"guardian-risk": "0.2.
|
|
63
|
+
"guardian-risk": "0.2.1"
|
|
59
64
|
},
|
|
60
65
|
"scripts": {
|
|
61
66
|
"build": "tsup",
|
package/dist/index.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;AA4BA,IAAM,WAAA,GAAwC;AAAA,EAC5C,KAAA,EAAO,CAAA;AAAA,EACP,IAAA,EAAM,CAAA;AAAA,EACN,IAAA,EAAM,CAAA;AAAA,EACN,KAAA,EAAO;AACT,CAAA;AAEA,IAAM,WAAA,GAAuB;AAAA,EAC3B,MAAM,KAAA,EAAa;AACjB,IAAA,MAAM,OAAA,GAAU,KAAK,SAAA,CAAU;AAAA,MAC7B,OAAO,KAAA,CAAM,KAAA;AAAA,MACb,SAAS,KAAA,CAAM,OAAA;AAAA,MACf,KAAA,EAAO,MAAM,MAAA,CAAO,KAAA;AAAA,MACpB,SAAA,EAAW,MAAM,MAAA,CAAO,KAAA;AAAA,MACxB,YAAA,EAAc,KAAA,CAAM,MAAA,CAAO,YAAA,CAAa,MAAA;AAAA,MACxC,WAAW,KAAA,CAAM;AAAA,KAClB,CAAA;AACD,IAAA,OAAA,CAAQ,GAAA,CAAI,CAAA,gBAAA,EAAmB,OAAO,CAAA,CAAE,CAAA;AAAA,EAC1C;AACF,CAAA;AAQO,SAAS,YAAA,CAAa,OAAA,GAA+B,EAAC,EAAW;AACtE,EAAA,MAAM,EAAE,KAAA,GAAQ,MAAA,EAAQ,OAAO,WAAA,EAAa,QAAA,GAAW,GAAE,GAAI,OAAA;AAE7D,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,sBAAA;AAAA,IACN,QAAQ,SAAA,EAAW;AAGZ,IAEP;AAAA,GACF;AACF;AAKO,SAAS,SAAA,CACd,MAAA,EACA,OAAA,GAA+B,EAAC,EAC1B;AACN,EAAA,MAAM,EAAE,KAAA,GAAQ,MAAA,EAAQ,OAAO,WAAA,EAAa,QAAA,GAAW,GAAE,GAAI,OAAA;AAE7D,EAAA,IAAI,MAAA,CAAO,QAAQ,QAAA,EAAU;AAC3B,IAAA;AAAA,EACF;AAEA,EAAA,MAAM,UAAA,GAAa,eAAA,CAAgB,MAAA,EAAQ,KAAK,CAAA;AAEhD,EAAA,IAAA,CAAK,KAAA,CAAM;AAAA,IACT,KAAA,EAAO,UAAA;AAAA,IACP,SAAS,CAAA,wBAAA,EAA2B,MAAA,CAAO,KAAK,CAAA,EAAA,EAAK,OAAO,KAAK,CAAA,CAAA,CAAA;AAAA,IACjE,MAAA;AAAA,IACA,SAAA,EAAA,iBAAW,IAAI,IAAA,EAAK,EAAE,WAAA;AAAY,GACnC,CAAA;AACH;AAKO,SAAS,aAAA,CACd,QAAA,EACA,OAAA,GAA+B,EAAC,EACpB;AACZ,EAAA,MAAM,MAAA,GAAS,SAAS,OAAA,EAAQ;AAChC,EAAA,SAAA,CAAU,QAAQ,OAAO,CAAA;AACzB,EAAA,OAAO,MAAA;AACT;AAEA,SAAS,eAAA,CAAgB,QAAoB,UAAA,EAAgC;AAC3E,EAAA,IAAI,MAAA,CAAO,UAAU,UAAA,EAAY;AAC/B,IAAA,OAAO,OAAA;AAAA,EACT;AACA,EAAA,IAAI,MAAA,CAAO,UAAU,MAAA,EAAQ;AAC3B,IAAA,OAAO,MAAA;AAAA,EACT;AACA,EAAA,OAAO,UAAA;AACT;AAEA,SAAS,SAAA,CAAU,YAAsB,MAAA,EAA2B;AAClE,EAAA,OAAO,WAAA,CAAY,MAAM,CAAA,IAAK,WAAA,CAAY,UAAU,CAAA;AACtD","file":"index.cjs","sourcesContent":["import type { Plugin, RiskReport } from 'guardian-risk';\n\n/** Log severity level. */\nexport type LogLevel = 'debug' | 'info' | 'warn' | 'error';\n\n/** Sink that receives structured log entries. */\nexport interface LogSink {\n write(entry: LogEntry): void;\n}\n\n/** Structured log entry for a risk analysis. */\nexport interface LogEntry {\n readonly level: LogLevel;\n readonly message: string;\n readonly report: RiskReport;\n readonly timestamp: string;\n}\n\n/** Options for the logger plugin (stub). */\nexport interface LoggerPluginOptions {\n /** Minimum level to emit. */\n readonly level?: LogLevel;\n /** Custom sink. Defaults to console. */\n readonly sink?: LogSink;\n /** Log only when score exceeds this threshold. */\n readonly minScore?: number;\n}\n\nconst LEVEL_ORDER: Record<LogLevel, number> = {\n debug: 0,\n info: 1,\n warn: 2,\n error: 3,\n};\n\nconst defaultSink: LogSink = {\n write(entry): void {\n const payload = JSON.stringify({\n level: entry.level,\n message: entry.message,\n score: entry.report.score,\n riskLevel: entry.report.level,\n matchedRules: entry.report.matchedRules.length,\n timestamp: entry.timestamp,\n });\n console.log(`[guardian-risk] ${payload}`);\n },\n};\n\n/**\n * Logger plugin for guardian-risk.\n *\n * @stub Future versions will hook into analyze() automatically.\n * For now, use `logReport()` after `guardian.analyze()`.\n */\nexport function loggerPlugin(options: LoggerPluginOptions = {}): Plugin {\n const { level = 'info', sink = defaultSink, minScore = 0 } = options;\n\n return {\n name: 'guardian-risk-logger',\n install(_guardian) {\n void level;\n void sink;\n void minScore;\n // Stub: will wrap analyze() and emit audit logs automatically\n },\n };\n}\n\n/**\n * Log a risk report to the configured sink.\n */\nexport function logReport(\n report: RiskReport,\n options: LoggerPluginOptions = {},\n): void {\n const { level = 'info', sink = defaultSink, minScore = 0 } = options;\n\n if (report.score < minScore) {\n return;\n }\n\n const entryLevel = resolveLogLevel(report, level);\n\n sink.write({\n level: entryLevel,\n message: `Risk analysis complete: ${report.level} (${report.score})`,\n report,\n timestamp: new Date().toISOString(),\n });\n}\n\n/**\n * Analyze and log in one step.\n */\nexport function analyzeAndLog(\n guardian: import('guardian-risk').Guardian,\n options: LoggerPluginOptions = {},\n): RiskReport {\n const report = guardian.analyze();\n logReport(report, options);\n return report;\n}\n\nfunction resolveLogLevel(report: RiskReport, configured: LogLevel): LogLevel {\n if (report.level === 'CRITICAL') {\n return 'error';\n }\n if (report.level === 'HIGH') {\n return 'warn';\n }\n return configured;\n}\n\nfunction shouldLog(configured: LogLevel, actual: LogLevel): boolean {\n return LEVEL_ORDER[actual] >= LEVEL_ORDER[configured];\n}\n\nexport { shouldLog };\n"]}
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";AA4BA,IAAM,WAAA,GAAwC;AAAA,EAC5C,KAAA,EAAO,CAAA;AAAA,EACP,IAAA,EAAM,CAAA;AAAA,EACN,IAAA,EAAM,CAAA;AAAA,EACN,KAAA,EAAO;AACT,CAAA;AAEA,IAAM,WAAA,GAAuB;AAAA,EAC3B,MAAM,KAAA,EAAa;AACjB,IAAA,MAAM,OAAA,GAAU,KAAK,SAAA,CAAU;AAAA,MAC7B,OAAO,KAAA,CAAM,KAAA;AAAA,MACb,SAAS,KAAA,CAAM,OAAA;AAAA,MACf,KAAA,EAAO,MAAM,MAAA,CAAO,KAAA;AAAA,MACpB,SAAA,EAAW,MAAM,MAAA,CAAO,KAAA;AAAA,MACxB,YAAA,EAAc,KAAA,CAAM,MAAA,CAAO,YAAA,CAAa,MAAA;AAAA,MACxC,WAAW,KAAA,CAAM;AAAA,KAClB,CAAA;AACD,IAAA,OAAA,CAAQ,GAAA,CAAI,CAAA,gBAAA,EAAmB,OAAO,CAAA,CAAE,CAAA;AAAA,EAC1C;AACF,CAAA;AAQO,SAAS,YAAA,CAAa,OAAA,GAA+B,EAAC,EAAW;AACtE,EAAA,MAAM,EAAE,KAAA,GAAQ,MAAA,EAAQ,OAAO,WAAA,EAAa,QAAA,GAAW,GAAE,GAAI,OAAA;AAE7D,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,sBAAA;AAAA,IACN,QAAQ,SAAA,EAAW;AAGZ,IAEP;AAAA,GACF;AACF;AAKO,SAAS,SAAA,CACd,MAAA,EACA,OAAA,GAA+B,EAAC,EAC1B;AACN,EAAA,MAAM,EAAE,KAAA,GAAQ,MAAA,EAAQ,OAAO,WAAA,EAAa,QAAA,GAAW,GAAE,GAAI,OAAA;AAE7D,EAAA,IAAI,MAAA,CAAO,QAAQ,QAAA,EAAU;AAC3B,IAAA;AAAA,EACF;AAEA,EAAA,MAAM,UAAA,GAAa,eAAA,CAAgB,MAAA,EAAQ,KAAK,CAAA;AAEhD,EAAA,IAAA,CAAK,KAAA,CAAM;AAAA,IACT,KAAA,EAAO,UAAA;AAAA,IACP,SAAS,CAAA,wBAAA,EAA2B,MAAA,CAAO,KAAK,CAAA,EAAA,EAAK,OAAO,KAAK,CAAA,CAAA,CAAA;AAAA,IACjE,MAAA;AAAA,IACA,SAAA,EAAA,iBAAW,IAAI,IAAA,EAAK,EAAE,WAAA;AAAY,GACnC,CAAA;AACH;AAKO,SAAS,aAAA,CACd,QAAA,EACA,OAAA,GAA+B,EAAC,EACpB;AACZ,EAAA,MAAM,MAAA,GAAS,SAAS,OAAA,EAAQ;AAChC,EAAA,SAAA,CAAU,QAAQ,OAAO,CAAA;AACzB,EAAA,OAAO,MAAA;AACT;AAEA,SAAS,eAAA,CAAgB,QAAoB,UAAA,EAAgC;AAC3E,EAAA,IAAI,MAAA,CAAO,UAAU,UAAA,EAAY;AAC/B,IAAA,OAAO,OAAA;AAAA,EACT;AACA,EAAA,IAAI,MAAA,CAAO,UAAU,MAAA,EAAQ;AAC3B,IAAA,OAAO,MAAA;AAAA,EACT;AACA,EAAA,OAAO,UAAA;AACT;AAEA,SAAS,SAAA,CAAU,YAAsB,MAAA,EAA2B;AAClE,EAAA,OAAO,WAAA,CAAY,MAAM,CAAA,IAAK,WAAA,CAAY,UAAU,CAAA;AACtD","file":"index.js","sourcesContent":["import type { Plugin, RiskReport } from 'guardian-risk';\n\n/** Log severity level. */\nexport type LogLevel = 'debug' | 'info' | 'warn' | 'error';\n\n/** Sink that receives structured log entries. */\nexport interface LogSink {\n write(entry: LogEntry): void;\n}\n\n/** Structured log entry for a risk analysis. */\nexport interface LogEntry {\n readonly level: LogLevel;\n readonly message: string;\n readonly report: RiskReport;\n readonly timestamp: string;\n}\n\n/** Options for the logger plugin (stub). */\nexport interface LoggerPluginOptions {\n /** Minimum level to emit. */\n readonly level?: LogLevel;\n /** Custom sink. Defaults to console. */\n readonly sink?: LogSink;\n /** Log only when score exceeds this threshold. */\n readonly minScore?: number;\n}\n\nconst LEVEL_ORDER: Record<LogLevel, number> = {\n debug: 0,\n info: 1,\n warn: 2,\n error: 3,\n};\n\nconst defaultSink: LogSink = {\n write(entry): void {\n const payload = JSON.stringify({\n level: entry.level,\n message: entry.message,\n score: entry.report.score,\n riskLevel: entry.report.level,\n matchedRules: entry.report.matchedRules.length,\n timestamp: entry.timestamp,\n });\n console.log(`[guardian-risk] ${payload}`);\n },\n};\n\n/**\n * Logger plugin for guardian-risk.\n *\n * @stub Future versions will hook into analyze() automatically.\n * For now, use `logReport()` after `guardian.analyze()`.\n */\nexport function loggerPlugin(options: LoggerPluginOptions = {}): Plugin {\n const { level = 'info', sink = defaultSink, minScore = 0 } = options;\n\n return {\n name: 'guardian-risk-logger',\n install(_guardian) {\n void level;\n void sink;\n void minScore;\n // Stub: will wrap analyze() and emit audit logs automatically\n },\n };\n}\n\n/**\n * Log a risk report to the configured sink.\n */\nexport function logReport(\n report: RiskReport,\n options: LoggerPluginOptions = {},\n): void {\n const { level = 'info', sink = defaultSink, minScore = 0 } = options;\n\n if (report.score < minScore) {\n return;\n }\n\n const entryLevel = resolveLogLevel(report, level);\n\n sink.write({\n level: entryLevel,\n message: `Risk analysis complete: ${report.level} (${report.score})`,\n report,\n timestamp: new Date().toISOString(),\n });\n}\n\n/**\n * Analyze and log in one step.\n */\nexport function analyzeAndLog(\n guardian: import('guardian-risk').Guardian,\n options: LoggerPluginOptions = {},\n): RiskReport {\n const report = guardian.analyze();\n logReport(report, options);\n return report;\n}\n\nfunction resolveLogLevel(report: RiskReport, configured: LogLevel): LogLevel {\n if (report.level === 'CRITICAL') {\n return 'error';\n }\n if (report.level === 'HIGH') {\n return 'warn';\n }\n return configured;\n}\n\nfunction shouldLog(configured: LogLevel, actual: LogLevel): boolean {\n return LEVEL_ORDER[actual] >= LEVEL_ORDER[configured];\n}\n\nexport { shouldLog };\n"]}
|