diff --git a/bitwarden_license/bit-common/src/dirt/reports/risk-insights/services/domain/risk-insights-type-guards.spec.ts b/bitwarden_license/bit-common/src/dirt/reports/risk-insights/services/domain/risk-insights-type-guards.spec.ts index 6c130dc77fa..3e32937d9e2 100644 --- a/bitwarden_license/bit-common/src/dirt/reports/risk-insights/services/domain/risk-insights-type-guards.spec.ts +++ b/bitwarden_license/bit-common/src/dirt/reports/risk-insights/services/domain/risk-insights-type-guards.spec.ts @@ -158,7 +158,6 @@ describe("Risk Insights Type Guards", () => { totalCriticalMemberCount: 4, totalCriticalAtRiskMemberCount: 1, totalCriticalAtRiskApplicationCount: 1, - newApplications: ["app-1", "app-2"], }; expect(() => validateOrganizationReportSummary(validData)).not.toThrow(); @@ -174,7 +173,6 @@ describe("Risk Insights Type Guards", () => { totalCriticalMemberCount: 4, totalCriticalAtRiskMemberCount: 1, totalCriticalAtRiskApplicationCount: 1, - newApplications: ["app-1"], }; expect(() => validateOrganizationReportSummary(invalidData)).toThrow( @@ -186,7 +184,6 @@ describe("Risk Insights Type Guards", () => { const invalidData = { totalMemberCount: 10, // missing multiple fields - newApplications: ["app-1"], }; expect(() => validateOrganizationReportSummary(invalidData)).toThrow( @@ -204,43 +201,6 @@ describe("Risk Insights Type Guards", () => { totalCriticalMemberCount: 4, totalCriticalAtRiskMemberCount: 1, totalCriticalAtRiskApplicationCount: 1, - newApplications: ["app-1"], - }; - - expect(() => validateOrganizationReportSummary(invalidData)).toThrow( - /Invalid OrganizationReportSummary/, - ); - }); - - it("should throw error for non-array newApplications", () => { - const invalidData = { - totalMemberCount: 10, - totalApplicationCount: 5, - totalAtRiskMemberCount: 2, - totalAtRiskApplicationCount: 1, - totalCriticalApplicationCount: 3, - totalCriticalMemberCount: 4, - totalCriticalAtRiskMemberCount: 1, - totalCriticalAtRiskApplicationCount: 1, - newApplications: "not-an-array", - }; - - expect(() => validateOrganizationReportSummary(invalidData)).toThrow( - /Invalid OrganizationReportSummary.*newApplications/, - ); - }); - - it("should throw error for empty string in newApplications", () => { - const invalidData = { - totalMemberCount: 10, - totalApplicationCount: 5, - totalAtRiskMemberCount: 2, - totalAtRiskApplicationCount: 1, - totalCriticalApplicationCount: 3, - totalCriticalMemberCount: 4, - totalCriticalAtRiskMemberCount: 1, - totalCriticalAtRiskApplicationCount: 1, - newApplications: ["app-1", "", "app-3"], // empty string }; expect(() => validateOrganizationReportSummary(invalidData)).toThrow( @@ -551,7 +511,6 @@ describe("Risk Insights Type Guards", () => { totalCriticalMemberCount: 4, totalCriticalAtRiskMemberCount: 1, totalCriticalAtRiskApplicationCount: 1, - newApplications: ["app-1"], }; expect(isOrganizationReportSummary(validData)).toBe(true); }); @@ -566,7 +525,6 @@ describe("Risk Insights Type Guards", () => { totalCriticalMemberCount: 4, totalCriticalAtRiskMemberCount: 1, totalCriticalAtRiskApplicationCount: 1, - newApplications: ["app-1"], }; expect(isOrganizationReportSummary(invalidData)).toBe(false); }); @@ -581,7 +539,6 @@ describe("Risk Insights Type Guards", () => { totalCriticalMemberCount: 4, totalCriticalAtRiskMemberCount: 1, totalCriticalAtRiskApplicationCount: 1, - newApplications: ["app-1"], }; expect(isOrganizationReportSummary(invalidData)).toBe(false); }); @@ -596,7 +553,6 @@ describe("Risk Insights Type Guards", () => { totalCriticalMemberCount: 4, totalCriticalAtRiskMemberCount: 1, totalCriticalAtRiskApplicationCount: 1, - newApplications: ["app-1"], }; expect(isOrganizationReportSummary(invalidData)).toBe(false); }); @@ -611,7 +567,6 @@ describe("Risk Insights Type Guards", () => { totalCriticalMemberCount: 4, totalCriticalAtRiskMemberCount: 1, totalCriticalAtRiskApplicationCount: 1, - newApplications: ["app-1"], extraField: "should be rejected", }; expect(isOrganizationReportSummary(invalidData)).toBe(false); diff --git a/bitwarden_license/bit-common/src/dirt/reports/risk-insights/services/domain/risk-insights-type-guards.ts b/bitwarden_license/bit-common/src/dirt/reports/risk-insights/services/domain/risk-insights-type-guards.ts index e3bcb3e18a2..c225586d6f7 100644 --- a/bitwarden_license/bit-common/src/dirt/reports/risk-insights/services/domain/risk-insights-type-guards.ts +++ b/bitwarden_license/bit-common/src/dirt/reports/risk-insights/services/domain/risk-insights-type-guards.ts @@ -181,7 +181,6 @@ export function isOrganizationReportSummary(obj: any): obj is OrganizationReport "totalCriticalMemberCount", "totalCriticalAtRiskMemberCount", "totalCriticalAtRiskApplicationCount", - "newApplications", ]; const actualKeys = Object.keys(obj); const hasUnexpectedProps = actualKeys.some((key) => !allowedKeys.includes(key)); @@ -229,12 +228,7 @@ export function isOrganizationReportSummary(obj: any): obj is OrganizationReport Number.isFinite(obj.totalCriticalAtRiskApplicationCount) && Number.isSafeInteger(obj.totalCriticalAtRiskApplicationCount) && obj.totalCriticalAtRiskApplicationCount >= 0 && - obj.totalCriticalAtRiskApplicationCount <= MAX_COUNT && - Array.isArray(obj.newApplications) && - obj.newApplications.length <= MAX_ARRAY_LENGTH && - obj.newApplications.every( - (app: any) => typeof app === "string" && app.length > 0 && app.length <= MAX_STRING_LENGTH, - ) + obj.totalCriticalAtRiskApplicationCount <= MAX_COUNT ); } @@ -346,9 +340,6 @@ export function validateOrganizationReportSummary(data: any): OrganizationReport if (typeof data?.totalCriticalAtRiskApplicationCount !== "number") { missingFields.push("totalCriticalAtRiskApplicationCount (number)"); } - if (!Array.isArray(data?.newApplications)) { - missingFields.push("newApplications (string[])"); - } throw new Error( `Invalid OrganizationReportSummary: ${missingFields.length > 0 ? `missing or invalid fields: ${missingFields.join(", ")}` : "structure validation failed"}`,