Security Scorecard

The scorecard analyses your upload security configuration and returns a letter grade (A–F) with specific findings and actionable recommendations. Great for CI gates, pull request checks, and sharing on social media.

Overview

Seven security checks are evaluated, each with a weighted score out of 100:

API usage

const { generateScorecard } = require('pompelmi');

const scorecard = await generateScorecard({
  scanEnabled:              true,
  mimeTypeAllowlist:        ['image/jpeg', 'image/png', 'application/pdf'],
  fileSizeLimit:            10 * 1024 * 1024, // 10 MB
  diskWriteBeforeScan:      false,
  scanErrorBehavior:        'reject',
  clamdUnavailableBehavior: 'reject',
  tlsEnabled:               true,
});

console.log(scorecard.grade);        // 'A'
console.log(scorecard.score);        // 100
console.log(scorecard.findings);     // array of { check, status, weight }
console.log(scorecard.recommendations); // [] (empty when all pass)

Return value

{
  grade:           'A' | 'B' | 'C' | 'D' | 'F';
  score:           number; // 0–100
  findings:        Array<{ check: string; status: 'pass' | 'fail'; weight: number }>;
  recommendations: string[];
}

CLI usage

# Grade your config interactively
npx pompelmi scorecard --config ./pompelmi.config.js

Example output:

  Upload Security Scorecard

  Grade: A   Score: 100/100

  ✓  Virus scanning enabled                    (weight: 30)
  ✓  MIME type allowlist                        (weight: 20)
  ✓  File size limit                            (weight: 10)
  ✓  No disk write before scan                  (weight: 15)
  ✓  Scan error behavior is reject              (weight: 10)
  ✓  clamd unavailable behavior is reject       (weight: 10)
  ✓  TLS enabled on upload endpoint             (weight: 5)

Checks & weights

Config keyCheckWeightPass condition
scanEnabledVirus scanning enabled30true
mimeTypeAllowlistMIME type allowlist20Non-empty array
diskWriteBeforeScanNo disk write before scan15false
fileSizeLimitFile size limit10Positive number
scanErrorBehaviorScan error behavior is reject10'reject'
clamdUnavailableBehaviorclamd unavailable behavior is reject10'reject'
tlsEnabledTLS enabled on upload endpoint5true

Grade thresholds

GradeScore range
A90–100
B75–89
C60–74
D45–59
F0–44

Config file

Create a pompelmi.config.js at your project root and pass it via --config:

// pompelmi.config.js
module.exports = {
  scanEnabled:              true,
  mimeTypeAllowlist:        ['image/jpeg', 'image/png', 'application/pdf'],
  fileSizeLimit:            5 * 1024 * 1024,
  diskWriteBeforeScan:      false,
  scanErrorBehavior:        'reject',
  clamdUnavailableBehavior: 'reject',
  tlsEnabled:               true,
};

TypeScript

import { generateScorecard, ScorecardConfig, ScorecardResult } from 'pompelmi';

const config: ScorecardConfig = {
  scanEnabled: true,
  mimeTypeAllowlist: ['image/jpeg'],
  fileSizeLimit: 10_000_000,
  diskWriteBeforeScan: false,
  scanErrorBehavior: 'reject',
  clamdUnavailableBehavior: 'reject',
  tlsEnabled: true,
};

const result: ScorecardResult = await generateScorecard(config);