@produtype/core 1.18.0 → 1.19.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.
@@ -26,6 +26,26 @@ const blockComments_1 = require("../analyzer/blockComments");
26
26
  * and is left alone.
27
27
  */
28
28
  const PATTERN_DECLARATION = /^(?:const\s+\w+(?:\s*:[^=]+)?\s*=\s*)?\/(?:[^/\\]|\\.)+\/[gimsuy]*\s*[,;]?$/;
29
+ /**
30
+ * A header name on a line of its own says which header, not what value.
31
+ *
32
+ * saleor's ASGI handler writes the response headers as a list of tuples, so
33
+ * `b"access-control-allow-origin",` sits alone on line 50 and the origin it will
34
+ * carry is on line 51. Saleor only appends that pair when the caller's origin matched
35
+ * its allowlist, and answers 400 when it did not — a strict policy, reported at
36
+ * `high` as one with no restrictions, on the strength of a line that cannot show a
37
+ * policy because there is no value on it.
38
+ *
39
+ * The bare-string-in-a-list rule this file already records stays intact:
40
+ * `'django.contrib.auth',` in an INSTALLED_APPS array *is* the behaviour. A header
41
+ * name is not, for the reason above — it names the slot, and the slot is filled
42
+ * somewhere else.
43
+ */
44
+ const LONE_HEADER_NAME = /^[bru]?(['"`])([^'"`]+)\1\s*,?$/i;
45
+ function isALoneHeaderName(trimmed) {
46
+ const literal = LONE_HEADER_NAME.exec(trimmed);
47
+ return literal !== null && HTTP_HEADER_NAME.test(literal[2].replace(/\b[a-z]/g, (c) => c.toUpperCase()));
48
+ }
29
49
  /**
30
50
  * An entry that says what something is called.
31
51
  *
@@ -167,7 +187,7 @@ function declaresAType(trimmed) {
167
187
  }
168
188
  function declaresRatherThanDoes(line) {
169
189
  const trimmed = line.trim();
170
- return COMMENT_LINE.test(trimmed) || PATTERN_DECLARATION.test(trimmed) || declaresAType(trimmed) || spellsItsOwnName(trimmed) || NAMES_SOMETHING.test(trimmed);
190
+ return COMMENT_LINE.test(trimmed) || PATTERN_DECLARATION.test(trimmed) || declaresAType(trimmed) || spellsItsOwnName(trimmed) || NAMES_SOMETHING.test(trimmed) || isALoneHeaderName(trimmed);
171
191
  }
172
192
  /**
173
193
  * Whether this line may be quoted back to the reader as something the code does.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@produtype/core",
3
- "version": "1.18.0",
3
+ "version": "1.19.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": {