@produtype/core 1.15.0 → 1.16.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
+ * Rust's answer, which is a builder rather than a value.
731
+ *
732
+ * meilisearch calls `.send_wildcard()` and `.allow_any_origin()` on an
733
+ * `actix_cors::Cors` — the most explicit way there is to say "everybody" — and the
734
+ * report said "CORS configuration not detected". Third product in three releases
735
+ * scoring well while answering every origin on the web, after kimai's
736
+ * `nelmio_cors.yaml` and chatwoot's `origins '*'`.
737
+ *
738
+ * Nothing here is a header name or an `allowedOrigins` field. `Cors`,
739
+ * `allow_any_origin`, `allowed_origin` and `permissive` are actix-cors'; `CorsLayer`
740
+ * and `allow_origin` are tower-http's. The method says which branch it is:
741
+ * `allow_any_origin`, `permissive` and `Any` are open, a named origin is a choice.
742
+ *
743
+ * The tower-http half ships weaker and this says so: meilisearch is the actix case,
744
+ * and two axum services cloned looking for the other one — atuin and lapdev — turned
745
+ * out to configure no CORS at all. It is the same contract read from the same kind
746
+ * of builder, but no repository stands behind it yet.
747
+ */
748
+ const RUST_CORS_OPEN = [/\.allow_any_origin\s*\(/, /\.send_wildcard\s*\(/, /Cors::permissive\s*\(/, /CorsLayer::permissive\s*\(/, /\.allow_origin\s*\(\s*Any\b/];
749
+ const RUST_CORS_CHOSEN = [/\.allowed_origin\s*\(/, /\.allowed_origin_fn\s*\(/, /\.allow_origin\s*\(\s*["'[]/];
750
+ const rustSource = source.filter((f) => /\.rs$/.test(f));
751
+ if (rustSource.length > 0) {
752
+ const open = await (0, textSearch_1.searchInFiles)(ctx.root, rustSource, RUST_CORS_OPEN, 5);
753
+ const chosen = await (0, textSearch_1.searchInFiles)(ctx.root, rustSource, RUST_CORS_CHOSEN, 5);
754
+ for (const hit of open)
755
+ corsLoose.push(hit);
756
+ for (const hit of chosen)
757
+ corsStrict.push(hit);
758
+ }
729
759
  /**
730
760
  * Rails' answer, which is a gem with a small language of its own.
731
761
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@produtype/core",
3
- "version": "1.15.0",
3
+ "version": "1.16.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": {