@produtype/core 1.14.0 → 1.15.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.
@@ -726,6 +726,36 @@ async function detectSecurity(ctx) {
726
726
  * `CORS_ORIGIN_ALLOW_ALL`, which is what it was called before version 3.5 — is the
727
727
  * one line that opens it.
728
728
  */
729
+ /**
730
+ * Rails' answer, which is a gem with a small language of its own.
731
+ *
732
+ * chatwoot scored 98 and `production_ready` with its cross-origin policy reported
733
+ * as "not detected". It installs `rack-cors`, mounts `Rack::Cors` as the first
734
+ * middleware in `config/initializers/cors.rb`, and writes `origins '*'` — which
735
+ * opens `/packs/*`, `/audio/*`, `/public/api/*`, and everything else when
736
+ * `CW_API_ONLY_SERVER` is set. Not one of the words this check looked for appears
737
+ * in that file: the gem's DSL says `origins`, not `Access-Control-Allow-Origin`.
738
+ *
739
+ * `rack-cors`, `Rack::Cors` and `origins` are the gem's; the values are the
740
+ * author's. Every `origins` line is read, because the block lists one per rule and
741
+ * a permissive one beside a restricted one is still permissive.
742
+ */
743
+ for (const file of ctx.files.all.filter((f) => /\.rb$/.test(f))) {
744
+ const text = await (0, readTextFileSafe_1.readTextFileSafe)(ctx.root, file);
745
+ if (!text || !/\bRack::Cors\b/.test(text))
746
+ continue;
747
+ const lines = text.split(/\r?\n/);
748
+ for (let i = 0; i < lines.length; i++) {
749
+ const origins = /^\s*origins\s+(.+)$/.exec(lines[i]);
750
+ if (!origins || !(0, textSearch_1.isCitableLine)(lines[i].trim()))
751
+ continue;
752
+ const hit = { file, line: i + 1, snippet: lines[i].trim().slice(0, 200) };
753
+ if (/^['"]\*['"]/.test(origins[1].trim()))
754
+ corsLoose.push(hit);
755
+ else
756
+ corsStrict.push(hit);
757
+ }
758
+ }
729
759
  /**
730
760
  * Symfony's answer, which is a bundle and the file it reads.
731
761
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@produtype/core",
3
- "version": "1.14.0",
3
+ "version": "1.15.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": {