@dawans/promptshield
Version:
Secure your LLM stack with enterprise-grade RulePacks for AI safety scanning
55 lines (54 loc) • 1.68 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Report = void 0;
/**
* Represents a report to be generated
*/
class Report {
constructor(scanResult, format, options = {}) {
this.scanResult = scanResult;
this.format = format;
this.options = options;
}
/**
* Gets the total number of violations
*/
getTotalViolations() {
return this.scanResult.getTotalViolations();
}
/**
* Checks if the report should include summary
*/
shouldIncludeSummary() {
return this.options.includeSummary !== false;
}
/**
* Checks if the report should include metrics
*/
shouldIncludeMetrics() {
return this.options.includeMetrics !== false;
}
/**
* Gets filtered violations based on options
*/
getFilteredViolations() {
let violations = this.scanResult.violations;
if (this.options.severity && this.options.severity.length > 0) {
violations = this.scanResult.getViolationsBySeverity(this.options.severity);
}
if (this.options.category && this.options.category.length > 0) {
violations = this.scanResult.getViolationsByCategory(this.options.category);
}
if (this.options.maxViolations) {
violations = violations.slice(0, this.options.maxViolations);
}
if (this.options.offset) {
violations = violations.slice(this.options.offset);
}
if (this.options.limit) {
violations = violations.slice(0, this.options.limit);
}
return violations;
}
}
exports.Report = Report;