@produtype/core 1.13.0 → 1.14.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,44 @@ 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
|
+
* Symfony's answer, which is a bundle and the file it reads.
|
|
731
|
+
*
|
|
732
|
+
* kimai scored 93 and `production_ready` while its API answered every origin on
|
|
733
|
+
* earth: `config/packages/nelmio_cors.yaml` sets `allow_origin: []` in its defaults
|
|
734
|
+
* — the bundle's own comment says "for security reasons we do not allow CORS by
|
|
735
|
+
* default" — and then `allow_origin: ['*']` under `^/api/`. The report said "CORS
|
|
736
|
+
* configuration not detected" and gave no verdict at all.
|
|
737
|
+
*
|
|
738
|
+
* `nelmio/cors-bundle` is what a Symfony project installs for this, `nelmio_cors` is
|
|
739
|
+
* the configuration key the bundle defines and `allow_origin` is its setting. None
|
|
740
|
+
* of the three is the author's to choose; the values are.
|
|
741
|
+
*
|
|
742
|
+
* Every `allow_origin` in the file is read, not the first. A bundle configures
|
|
743
|
+
* defaults and then overrides them per path, and it is the override that is
|
|
744
|
+
* reachable — the same reason the ASP.NET branch above reports the open one where a
|
|
745
|
+
* project ships both.
|
|
746
|
+
*/
|
|
747
|
+
for (const file of ctx.files.all.filter((f) => /(^|\/)config\/packages\/[\w.-]*nelmio_cors[\w.-]*\.ya?ml$/i.test(f))) {
|
|
748
|
+
const text = await (0, readTextFileSafe_1.readTextFileSafe)(ctx.root, file);
|
|
749
|
+
if (!text)
|
|
750
|
+
continue;
|
|
751
|
+
const lines = text.split(/\r?\n/);
|
|
752
|
+
for (let i = 0; i < lines.length; i++) {
|
|
753
|
+
const origins = /^\s*allow_origin\s*:\s*(.*)$/.exec(lines[i]);
|
|
754
|
+
if (!origins)
|
|
755
|
+
continue;
|
|
756
|
+
const value = origins[1].trim();
|
|
757
|
+
/** An empty list is the bundle refusing every cross-origin request. */
|
|
758
|
+
if (value === '[]' || value === '')
|
|
759
|
+
continue;
|
|
760
|
+
const hit = { file, line: i + 1, snippet: lines[i].trim().slice(0, 200) };
|
|
761
|
+
if (/\[\s*['"]\*['"]\s*\]/.test(value) || value === "'*'" || value === '"*"')
|
|
762
|
+
corsLoose.push(hit);
|
|
763
|
+
else
|
|
764
|
+
corsStrict.push(hit);
|
|
765
|
+
}
|
|
766
|
+
}
|
|
729
767
|
/**
|
|
730
768
|
* Laravel's answer, which is a file with a name the framework chose.
|
|
731
769
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@produtype/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.14.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": {
|