@produtype/core 0.84.0 → 0.85.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.
@@ -139,6 +139,42 @@ async function detectDatabase(ctx) {
139
139
  for (const hit of hits)
140
140
  evidence.push({ type: 'dependency', value: hit });
141
141
  }
142
+ /**
143
+ * Laravel, whose database is named in a configuration file rather than in a package.
144
+ *
145
+ * PHP has one driver — PDO, in the runtime — so `composer.json` says nothing about
146
+ * which engine a project talks to, and nothing here read the place that does.
147
+ * Firefly III reported no data layer at all, above a `config/database.php` whose
148
+ * first line of substance is `'default' => env('DB_CONNECTION', 'mysql')`.
149
+ *
150
+ * Only the default is read. Laravel's file ships every driver it supports in the
151
+ * `connections` array whether the project uses them or not, so reading those would
152
+ * credit each project with four databases; the default is the one it actually falls
153
+ * back to when nothing is configured, which is the project's own statement.
154
+ */
155
+ const LARAVEL_DRIVERS = {
156
+ mysql: 'mysql',
157
+ mariadb: 'mysql',
158
+ pgsql: 'postgres',
159
+ sqlite: 'sqlite',
160
+ sqlsrv: 'sqlserver',
161
+ };
162
+ for (const file of ctx.files.all.filter((f) => /(^|\/)config\/database\.php$/.test(f))) {
163
+ const text = await (0, readTextFileSafe_1.readTextFileSafe)(ctx.root, file);
164
+ if (!text)
165
+ continue;
166
+ const defaultLine = /^\s*'default'\s*=>.*?['"]([a-z]+)['"]/m.exec(text);
167
+ const driver = defaultLine ? LARAVEL_DRIVERS[defaultLine[1]] : undefined;
168
+ if (!driver)
169
+ continue;
170
+ databases.add(driver);
171
+ evidence.push({
172
+ type: 'snippet',
173
+ value: defaultLine[0].trim().slice(0, 200),
174
+ file,
175
+ line: text.slice(0, defaultLine.index).split('\n').length,
176
+ });
177
+ }
142
178
  const dotnetHits = [
143
179
  ['postgres', ['Npgsql']],
144
180
  ['mysql', ['MySql.Data', 'Pomelo.EntityFrameworkCore.MySql']],
@@ -366,6 +366,31 @@ async function detectSecurity(ctx) {
366
366
  * `CORS_ORIGIN_ALLOW_ALL`, which is what it was called before version 3.5 — is the
367
367
  * one line that opens it.
368
368
  */
369
+ /**
370
+ * Laravel's answer, which is a file with a name the framework chose.
371
+ *
372
+ * `config/cors.php` is published by Laravel and read by its own middleware; a
373
+ * project either has it or does not. Firefly III has one whose `'allowed_origins'`
374
+ * is `['*']`, and the report said it had no cross-origin configuration at all —
375
+ * the worst direction for this check, because a project that opened itself to the
376
+ * whole web read as one that had not thought about it.
377
+ *
378
+ * The path is the anchor and the array is the answer: a bare `'*'` is the wide-open
379
+ * case, and a list of origins is one somebody chose.
380
+ */
381
+ for (const file of source.concat(ctx.files.all).filter((f) => /(^|\/)config\/cors\.php$/.test(f))) {
382
+ const text = await (0, readTextFileSafe_1.readTextFileSafe)(ctx.root, file);
383
+ if (!text)
384
+ continue;
385
+ const origins = /'allowed_origins'\s*=>\s*\[([^\]]*)\]/.exec(text);
386
+ const line = origins ? text.slice(0, origins.index).split('\n').length : 1;
387
+ const hit = { file, line, snippet: (origins?.[0] ?? "config/cors.php").replace(/\s+/g, ' ').trim().slice(0, 200) };
388
+ if (!origins || /^\s*'\*'\s*,?\s*$/.test(origins[1]))
389
+ corsLoose.push(hit);
390
+ else
391
+ corsStrict.push(hit);
392
+ break;
393
+ }
369
394
  const django = await (0, djangoSettings_1.findDjangoSettings)(ctx);
370
395
  if (django) {
371
396
  const middlewareLine = django.text
@@ -114,6 +114,19 @@ export interface ProductionReadinessReport {
114
114
  findingsByCategory: Record<Category, Finding[]>;
115
115
  criticalIssues: Finding[];
116
116
  warnings: Finding[];
117
+ /**
118
+ * The observed rules that passed. Not the capabilities a profile asked for and found.
119
+ *
120
+ * Those live in `productProfile.capabilities`, every one of them, with its own
121
+ * status — and they are deliberately not repeated here. A met expectation and the
122
+ * observed rule underneath it are the same verification stated twice: counting both
123
+ * made "basic web security: 4 checks verified" read as 7.
124
+ *
125
+ * Written down because the shape misleads on the way in. Reading `findings` and
126
+ * `passedChecks` and finding no capability in either looks exactly like a capability
127
+ * no project ever satisfies, and it is not: it is the wrong array. That reading was
128
+ * made twice while surveying this analyzer's own corpus.
129
+ */
117
130
  passedChecks: Finding[];
118
131
  suggestedNextSteps: string[];
119
132
  technicalEvidence: Array<{
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@produtype/core",
3
- "version": "0.84.0",
3
+ "version": "0.85.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": {