@produtype/core 0.37.0 → 0.38.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.
@@ -14,6 +14,7 @@ const evidenceDigest_1 = require("./evidenceDigest");
14
14
  const complianceMapping_1 = require("./complianceMapping");
15
15
  const executiveSummary_1 = require("./executiveSummary");
16
16
  const remediationCatalog_1 = require("../planner/remediationCatalog");
17
+ const detectPackaging_1 = require("../analyzer/detectPackaging");
17
18
  // Derived from the union in report/types.ts, so a new category cannot be missed here.
18
19
  function bySeverityPriority(f) {
19
20
  const order = {
@@ -50,6 +51,27 @@ function determineExpectationMode(requestedProfile, productProfile, expectationS
50
51
  }
51
52
  return 'explicit-profile';
52
53
  }
54
+ /**
55
+ * A finding whose every citation is in the documentation site or a playground.
56
+ *
57
+ * Medusa was told its CORS policy was open, evidenced from `www/apps/cloud/`, and that
58
+ * its Stripe webhook handling was unverified, evidenced from the documentation's
59
+ * `sidebar.mjs` — the navigation menu that lists a page about webhooks. Vite keeps ten
60
+ * Express servers under `playground/` for the same kind of reason.
61
+ *
62
+ * These are not false matches: the lines are there. They are matches about something
63
+ * other than the product, and a report that cannot tell the two apart tells its reader
64
+ * to go and fix a documentation site.
65
+ *
66
+ * Only where the repository has source outside those directories. A documentation site
67
+ * that *is* the product keeps every finding it earns.
68
+ */
69
+ function onlyEvidencedInDocumentation(finding, hasProductSource) {
70
+ if (!hasProductSource)
71
+ return false;
72
+ const cited = finding.evidence.filter((item) => item.file);
73
+ return cited.length > 0 && cited.every((item) => detectPackaging_1.DOCS_DIRECTORIES.test(item.file));
74
+ }
53
75
  function buildReport(analysis, options) {
54
76
  const observedFindings = (0, ruleEngine_1.runRules)(analysis);
55
77
  const observedScore = (0, score_1.computeScore)(observedFindings);
@@ -109,7 +131,23 @@ function buildReport(analysis, options) {
109
131
  expectationScore = evaluated.result.score;
110
132
  }
111
133
  }
112
- const findings = (0, evidenceDigest_1.withEvidenceDigest)((0, businessImpact_1.withBusinessImpact)([...observedFindings, ...expectationFindings].sort((a, b) => bySeverityPriority(a) - bySeverityPriority(b))));
134
+ /**
135
+ * Whether this repository is more than its documentation.
136
+ *
137
+ * If every source file lives under `docs/` or `website/`, the documentation is the
138
+ * product and its findings are the product's.
139
+ */
140
+ const hasProductSource = analysis.files.source.some((file) => !detectPackaging_1.DOCS_DIRECTORIES.test(file));
141
+ const findings = (0, evidenceDigest_1.withEvidenceDigest)((0, businessImpact_1.withBusinessImpact)([...observedFindings, ...expectationFindings]
142
+ .map((finding) => onlyEvidencedInDocumentation(finding, hasProductSource)
143
+ ? {
144
+ ...finding,
145
+ status: 'unknown',
146
+ severity: 'info',
147
+ description: `${finding.description} Every line behind this is in the documentation site or a playground rather than in the product, so nothing here says the product does it.`,
148
+ }
149
+ : finding)
150
+ .sort((a, b) => bySeverityPriority(a) - bySeverityPriority(b))));
113
151
  const combinedScore = expectationScore === undefined
114
152
  ? observedScore
115
153
  : Math.max(0, Math.min(100, Math.round((observedScore * 0.6) + (expectationScore * 0.4))));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@produtype/core",
3
- "version": "0.37.0",
3
+ "version": "0.38.0",
4
4
  "description": "Deterministic CLI and library that analyzes a web application repository and reports how far it is from production-ready for the kind of product it is meant to be.",
5
5
  "license": "MIT",
6
6
  "bin": {