import { describe, it, expect } from "vitest";
import { LOGIC_VULN_CWE_MAP, LOGIC_VULN_OWASP_MAP, LOGIC_VULN_SEVERITY_MAP, FRAMEWORK_DETECTION_PATTERNS, } from "../../../scanners/logic/types.js";
describe("logic types", () => {
    describe("LOGIC_VULN_CWE_MAP", () => {
        it("maps all vulnerability types to CWE IDs", () => {
            const vulnTypes = [
                "bola",
                "idor",
                "bfla",
                "mass-assignment",
                "race-condition-auth",
                "privilege-escalation",
                "missing-auth",
                "missing-authz",
                "direct-db-access",
                "horizontal-priv-esc",
                "vertical-priv-esc",
            ];
            for (const vulnType of vulnTypes) {
                expect(LOGIC_VULN_CWE_MAP[vulnType]).toBeDefined();
                expect(LOGIC_VULN_CWE_MAP[vulnType].length).toBeGreaterThan(0);
                expect(LOGIC_VULN_CWE_MAP[vulnType][0]).toMatch(/^CWE-\d+$/);
            }
        });
        it("contains correct CWE for BOLA", () => {
            expect(LOGIC_VULN_CWE_MAP["bola"]).toContain("CWE-639");
        });
        it("contains correct CWE for missing-auth", () => {
            expect(LOGIC_VULN_CWE_MAP["missing-auth"]).toContain("CWE-306");
        });
    });
    describe("LOGIC_VULN_OWASP_MAP", () => {
        it("maps all vulnerability types to OWASP references", () => {
            const vulnTypes = [
                "bola",
                "idor",
                "bfla",
                "mass-assignment",
                "privilege-escalation",
            ];
            for (const vulnType of vulnTypes) {
                expect(LOGIC_VULN_OWASP_MAP[vulnType]).toBeDefined();
                expect(LOGIC_VULN_OWASP_MAP[vulnType].length).toBeGreaterThan(0);
                expect(LOGIC_VULN_OWASP_MAP[vulnType][0]).toMatch(/^OWASP/);
            }
        });
        it("maps BOLA to API1:2023", () => {
            expect(LOGIC_VULN_OWASP_MAP["bola"]).toContain("OWASP API1:2023");
        });
    });
    describe("LOGIC_VULN_SEVERITY_MAP", () => {
        it("maps privilege escalation to critical", () => {
            expect(LOGIC_VULN_SEVERITY_MAP["privilege-escalation"]).toBe("critical");
        });
        it("maps missing-auth to critical", () => {
            expect(LOGIC_VULN_SEVERITY_MAP["missing-auth"]).toBe("critical");
        });
        it("maps bola to high", () => {
            expect(LOGIC_VULN_SEVERITY_MAP["bola"]).toBe("high");
        });
        it("maps mass-assignment to medium", () => {
            expect(LOGIC_VULN_SEVERITY_MAP["mass-assignment"]).toBe("medium");
        });
    });
    describe("FRAMEWORK_DETECTION_PATTERNS", () => {
        it("defines patterns for common frameworks", () => {
            const frameworks = ["nextjs", "express", "fastify", "nestjs", "django", "flask"];
            for (const framework of frameworks) {
                const patterns = FRAMEWORK_DETECTION_PATTERNS[framework];
                expect(patterns).toBeDefined();
                expect(patterns.packageNames).toBeDefined();
            }
        });
        it("Next.js patterns include next package", () => {
            expect(FRAMEWORK_DETECTION_PATTERNS.nextjs.packageNames).toContain("next");
        });
        it("Express patterns include express package", () => {
            expect(FRAMEWORK_DETECTION_PATTERNS.express.packageNames).toContain("express");
        });
        it("NestJS patterns include @nestjs/core package", () => {
            expect(FRAMEWORK_DETECTION_PATTERNS.nestjs.packageNames).toContain("@nestjs/core");
        });
    });
});
//# sourceMappingURL=types.test.js.map