@produtype/core 1.7.0 → 1.7.1

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.
@@ -233,6 +233,20 @@ function isTestOrExamplePath(file) {
233
233
  || /\.(e2e|e2e-spec|cy|stories)\.(ts|tsx|js|jsx|mjs|cjs)$/i.test(file)
234
234
  || /_spec\.rb$/i.test(file)
235
235
  || /_test\.(go|py|rb|java|cs|php)$/i.test(file)
236
+ || /_test\.exs$/i.test(file)
237
+ /**
238
+ * Mix names its environments, and the file name is the environment.
239
+ *
240
+ * `config/test.exs` and `config/dev.exs` are compiled only under `MIX_ENV=test` and
241
+ * `MIX_ENV=dev`; a production release carries `config/prod.exs` and
242
+ * `config/runtime.exs` and neither of the other two. supabase/realtime keeps
243
+ * `metrics_jwt_secret: "test"` in `config/test.exs` and it was the one `critical`
244
+ * in its report — a literal written to be fake, read as production configuration.
245
+ *
246
+ * The same argument as `_test.go`: the name is the toolchain's, not the author's,
247
+ * and it says which build the file is part of.
248
+ */
249
+ || /(^|\/)config\/(test|dev)\.exs$/i.test(file)
236
250
  || /(^|\/)test[-_][^/]+\.(ts|tsx|js|jsx|mjs|cjs|py)$/i.test(file)
237
251
  /**
238
252
  * The other half of the convention.
@@ -25,6 +25,23 @@ const GENERIC_SECRET_ASSIGNMENT_RE = /(JWT_SECRET|SECRET_KEY|SESSION_SECRET|API_
25
25
  * because the identifier does — so the value itself was never looked at.
26
26
  */
27
27
  const REDACTED_VALUE_RE = /[:=]\s*['"`](\*{2,}|x{3,}|<?\[?redacted\]?>?|hidden|\.{3,})['"`]/i;
28
+ /**
29
+ * A sentence assigned to a secret-named identifier is not a secret.
30
+ *
31
+ * `secret_key: "must be #{@secret_key_size} bytes in Base 64 URL alphabet"` is
32
+ * Livebook's validation message, returned when somebody types a bad key, and it was
33
+ * the one `critical` in its report. The finding is "Weak/fallback secret values" and
34
+ * the value was never looked at: every test above runs on the whole line, and the
35
+ * line says "secret" because the identifier does. The redaction rule beside this one
36
+ * was the same discovery made once, for one shape, and patched there.
37
+ *
38
+ * A secret is a token. It has no spaces in it and it is not a template with a
39
+ * variable in the middle — an error message, a label and a sentence all do. Three
40
+ * Elixir products raised this `critical` on the day Elixir became readable, and
41
+ * `critical` is the severity that caps maturity, so it was the loudest thing in each
42
+ * of three reports about products that had done nothing wrong.
43
+ */
44
+ const VALUE_IS_A_SENTENCE_RE = /[:=]\s*(['"`])[^'"`]*(?:\s|#\{|\$\{)[^'"`]*\1/;
28
45
  function classifySecretFallback(snippet) {
29
46
  if (/JWT_SECRET/i.test(snippet))
30
47
  return 'jwt';
@@ -166,6 +183,7 @@ async function detectEnv(ctx) {
166
183
  && !namesItself(m.snippet)
167
184
  && !valueIsAnIdentifier(m.snippet)
168
185
  && !REDACTED_VALUE_RE.test(m.snippet)
186
+ && !VALUE_IS_A_SENTENCE_RE.test(m.snippet)
169
187
  && !isTableEntry(m)
170
188
  && !isAnotherSettingsModule(m.file));
171
189
  for (const m of weakHits) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@produtype/core",
3
- "version": "1.7.0",
3
+ "version": "1.7.1",
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": {