logshield-cli 0.1.0 → 0.2.0

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.
@@ -1,54 +0,0 @@
1
- #!/usr/bin/env node
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- const readInput_1 = require("./readInput");
5
- const writeOutput_1 = require("./writeOutput");
6
- const summary_1 = require("./summary");
7
- const sanitizeLog_1 = require("../engine/sanitizeLog");
8
- const args = process.argv.slice(2);
9
- function hasFlag(flag) {
10
- return args.includes(flag);
11
- }
12
- function getFileArg() {
13
- return args.find((a) => !a.startsWith("--"));
14
- }
15
- async function main() {
16
- if (hasFlag("--help")) {
17
- console.log(`Usage: logshield scan [file]
18
-
19
- Options:
20
- --strict
21
- --json
22
- --summary
23
- --version
24
- --help
25
- `);
26
- process.exit(0);
27
- }
28
- if (hasFlag("--version")) {
29
- console.log("logshield v0.1.0");
30
- process.exit(0);
31
- }
32
- const command = args[0];
33
- if (command !== "scan") {
34
- console.error("Unknown command");
35
- process.exit(1);
36
- }
37
- const strict = hasFlag("--strict");
38
- const json = hasFlag("--json");
39
- const summary = hasFlag("--summary");
40
- const file = getFileArg();
41
- try {
42
- const input = await (0, readInput_1.readInput)(file);
43
- const result = (0, sanitizeLog_1.sanitizeLog)(input, { strict });
44
- (0, writeOutput_1.writeOutput)(result, { json });
45
- if (summary) {
46
- (0, summary_1.printSummary)(result.matches);
47
- }
48
- }
49
- catch (err) {
50
- console.error(err.message || "Unexpected error");
51
- process.exit(2);
52
- }
53
- }
54
- main();
@@ -1,57 +0,0 @@
1
- #!/usr/bin/env node
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- const readInput_1 = require("./readInput");
5
- const writeOutput_1 = require("./writeOutput");
6
- const summary_1 = require("./summary");
7
- const sanitizeLog_1 = require("../engine/sanitizeLog");
8
- const args = process.argv.slice(2);
9
- function hasFlag(flag) {
10
- return args.includes(flag);
11
- }
12
- function getFileArg() {
13
- const file = args[1];
14
- if (!file || file.startsWith("--"))
15
- return undefined;
16
- return file;
17
- }
18
- async function main() {
19
- if (hasFlag("--help")) {
20
- console.log(`Usage: logshield scan [file]
21
-
22
- Options:
23
- --strict
24
- --json
25
- --summary
26
- --version
27
- --help
28
- `);
29
- process.exit(0);
30
- }
31
- if (hasFlag("--version")) {
32
- console.log("logshield v0.1.0");
33
- process.exit(0);
34
- }
35
- const command = args[0];
36
- if (command !== "scan") {
37
- console.error("Unknown command");
38
- process.exit(1);
39
- }
40
- const strict = hasFlag("--strict");
41
- const json = hasFlag("--json");
42
- const summary = hasFlag("--summary");
43
- const file = getFileArg();
44
- try {
45
- const input = await (0, readInput_1.readInput)(file);
46
- const result = (0, sanitizeLog_1.sanitizeLog)(input, { strict });
47
- (0, writeOutput_1.writeOutput)(result, { json });
48
- if (summary) {
49
- (0, summary_1.printSummary)(result.matches);
50
- }
51
- }
52
- catch (err) {
53
- console.error(err.message || "Unexpected error");
54
- process.exit(2);
55
- }
56
- }
57
- main();
@@ -1,27 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.readInput = readInput;
7
- const node_fs_1 = __importDefault(require("node:fs"));
8
- async function readInput(file) {
9
- if (file) {
10
- if (!node_fs_1.default.existsSync(file)) {
11
- throw new Error(`File not found: ${file}`);
12
- }
13
- return node_fs_1.default.readFileSync(file, "utf8");
14
- }
15
- if (!process.stdin.isTTY) {
16
- return new Promise((resolve, reject) => {
17
- let data = "";
18
- process.stdin.setEncoding("utf8");
19
- process.stdin.on("data", chunk => {
20
- data += chunk;
21
- });
22
- process.stdin.on("end", () => resolve(data));
23
- process.stdin.on("error", reject);
24
- });
25
- }
26
- throw new Error("No input provided");
27
- }
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.printSummary = printSummary;
4
- function printSummary(matches) {
5
- const counter = {};
6
- for (const m of matches) {
7
- counter[m.rule] = (counter[m.rule] || 0) + 1;
8
- }
9
- process.stderr.write("LogShield Summary\n");
10
- for (const [rule, count] of Object.entries(counter)) {
11
- process.stderr.write(`${rule}: ${count}\n`);
12
- }
13
- }
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.writeOutput = writeOutput;
4
- function writeOutput(result, opts) {
5
- if (opts.json) {
6
- process.stdout.write(JSON.stringify(result));
7
- }
8
- else {
9
- process.stdout.write(result.output);
10
- }
11
- }
package/dist/cli/index.js DELETED
@@ -1,52 +0,0 @@
1
- #!/usr/bin/env node
2
- import { readInput } from "./readInput";
3
- import { writeOutput } from "./writeOutput";
4
- import { printSummary } from "./summary";
5
- import { sanitizeLog } from "../engine/sanitizeLog";
6
- const args = process.argv.slice(2);
7
- function hasFlag(flag) {
8
- return args.includes(flag);
9
- }
10
- function getFileArg() {
11
- return args.find((a) => !a.startsWith("--"));
12
- }
13
- async function main() {
14
- if (hasFlag("--help")) {
15
- console.log(`Usage: logshield scan [file]
16
-
17
- Options:
18
- --strict
19
- --json
20
- --summary
21
- --version
22
- --help
23
- `);
24
- process.exit(0);
25
- }
26
- if (hasFlag("--version")) {
27
- console.log("logshield v0.1.0");
28
- process.exit(0);
29
- }
30
- const command = args[0];
31
- if (command !== "scan") {
32
- console.error("Unknown command");
33
- process.exit(1);
34
- }
35
- const strict = hasFlag("--strict");
36
- const json = hasFlag("--json");
37
- const summary = hasFlag("--summary");
38
- const file = getFileArg();
39
- try {
40
- const input = await readInput(file);
41
- const result = sanitizeLog(input, { strict });
42
- writeOutput(result, { json });
43
- if (summary) {
44
- printSummary(result.matches);
45
- }
46
- }
47
- catch (err) {
48
- console.error(err.message || "Unexpected error");
49
- process.exit(2);
50
- }
51
- }
52
- main();
@@ -1,3 +0,0 @@
1
- {
2
- "type": "commonjs"
3
- }