@sasjs/utils 3.6.4 → 3.6.5

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.
@@ -0,0 +1,27 @@
1
+ #!/bin/bash
2
+
3
+ # Scan staged changes for secrets before anything else runs.
4
+ # The binary is pinned by the @nogoo9/gitleaks devDependency and lands
5
+ # in node_modules/.bin after npm i. Commits are blocked until it is
6
+ # installed so no clone silently skips the secrets scan.
7
+ gitleaks_bin=node_modules/.bin/gitleaks
8
+
9
+ if [ ! -x "$gitleaks_bin" ]; then
10
+ echo "❌ gitleaks not found - run 'npm i' to install it"
11
+ exit 1
12
+ fi
13
+
14
+ if ! "$gitleaks_bin" protect --staged --redact; then
15
+ echo "❌ gitleaks detected a potential secret in your staged changes"
16
+ echo "Remove the secret, or add a .gitleaksignore entry if it is a false positive"
17
+ exit 1
18
+ fi
19
+
20
+ # Avoid commits to the main branch
21
+ BRANCH=`git rev-parse --abbrev-ref HEAD`
22
+
23
+ if [[ "$BRANCH" =~ ^(master|main|develop)$ ]]; then
24
+ echo "You are on branch $BRANCH. Are you sure you want to commit to this branch?"
25
+ echo "If so, commit with -n to bypass the pre-commit hook."
26
+ exit 1
27
+ fi
package/package.json CHANGED
@@ -39,7 +39,8 @@
39
39
  "test": "jest --config=jest.config.js --coverage",
40
40
  "lint:fix": "npx prettier --write \"{src,test}/**/*.{ts,tsx,js,jsx,html,css,sass,less,json,yml,md,graphql}\"",
41
41
  "lint": "npx prettier --check \"{src,test}/**/*.{ts,tsx,js,jsx,html,css,sass,less,json,yml,md,graphql}\"",
42
- "semantic-release": "semantic-release"
42
+ "semantic-release": "semantic-release",
43
+ "setup": "git config core.hooksPath ./.git-hooks"
43
44
  },
44
45
  "repository": {
45
46
  "type": "git",
@@ -64,7 +65,8 @@
64
65
  "ts-jest": "29.4.14",
65
66
  "ts-loader": "9.6.2",
66
67
  "ts-node": "10.9.2",
67
- "typescript": "4.5.4"
68
+ "typescript": "4.5.4",
69
+ "@nogoo9/gitleaks": "8.30.1-post.2"
68
70
  },
69
71
  "dependencies": {
70
72
  "@fast-csv/format": "4.3.5",
@@ -77,5 +79,5 @@
77
79
  "jwt-decode": "3.1.2",
78
80
  "prompts": "2.4.2"
79
81
  },
80
- "version": "3.6.4"
82
+ "version": "3.6.5"
81
83
  }
package/utils/url.d.ts CHANGED
@@ -1,3 +1,14 @@
1
1
  export declare const urlOrigin: (str: string) => string;
2
+ /**
3
+ * The literal prefix is checked as well as the parsed protocol, because the URL
4
+ * parser normalises a backslash to a forward slash for special schemes:
5
+ * `new URL('http:\\server')` yields `http://server`. `valid-url`, which these
6
+ * replaced, required the literal prefix and so rejected such input.
7
+ *
8
+ * The prefix comparison is case-insensitive: the parser lowercases the scheme,
9
+ * so `HTTP://example.com` is a usable URL, and `valid-url` compared the scheme
10
+ * case-insensitively too. A backslash still fails, since it is not a slash in
11
+ * either case.
12
+ */
2
13
  export declare const isHttpUri: (str: string) => boolean;
3
14
  export declare const isHttpsUri: (str: string) => boolean;
package/utils/url.js CHANGED
@@ -23,8 +23,29 @@ const hasHttpProtocol = (str, protocol) => {
23
23
  return false;
24
24
  }
25
25
  };
26
- const isHttpUri = (str) => hasHttpProtocol(str, 'http:');
26
+ // The parser strips ASCII tab, newline and carriage return before parsing, so
27
+ // `new URL('http://exa\tmple.com')` yields `http://example.com`. Those are
28
+ // illegal in a URL, and `valid-url` rejected them.
29
+ const hasControlChars = (str) => /[\u0000-\u001F\u007F]/.test(str);
30
+ /**
31
+ * The literal prefix is checked as well as the parsed protocol, because the URL
32
+ * parser normalises a backslash to a forward slash for special schemes:
33
+ * `new URL('http:\\server')` yields `http://server`. `valid-url`, which these
34
+ * replaced, required the literal prefix and so rejected such input.
35
+ *
36
+ * The prefix comparison is case-insensitive: the parser lowercases the scheme,
37
+ * so `HTTP://example.com` is a usable URL, and `valid-url` compared the scheme
38
+ * case-insensitively too. A backslash still fails, since it is not a slash in
39
+ * either case.
40
+ */
41
+ const isHttpUri = (str) => typeof str === 'string' &&
42
+ !hasControlChars(str) &&
43
+ str.toLowerCase().startsWith('http://') &&
44
+ hasHttpProtocol(str, 'http:');
27
45
  exports.isHttpUri = isHttpUri;
28
- const isHttpsUri = (str) => hasHttpProtocol(str, 'https:');
46
+ const isHttpsUri = (str) => typeof str === 'string' &&
47
+ !hasControlChars(str) &&
48
+ str.toLowerCase().startsWith('https://') &&
49
+ hasHttpProtocol(str, 'https:');
29
50
  exports.isHttpsUri = isHttpsUri;
30
51
  //# sourceMappingURL=url.js.map
package/utils/url.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"url.js","sourceRoot":"","sources":["../../src/utils/url.ts"],"names":[],"mappings":";;;AAAO,MAAM,SAAS,GAAG,CAAC,GAAW,EAAE,EAAE;IACvC,IAAI,GAAG,KAAK,EAAE;QAAE,OAAO,GAAG,CAAA;IAE1B,IAAI,MAAM,CAAA;IAEV,IAAI;QACF,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,MAAM,CAAA;KAC7B;IAAC,OAAO,CAAC,EAAE;QACV,MAAM,IAAI,KAAK,CAAC,cAAc,CAAC,CAAA;KAChC;IAED,OAAO,MAAM,CAAA;AACf,CAAC,CAAA;AAZY,QAAA,SAAS,aAYrB;AAED,MAAM,eAAe,GAAG,CAAC,GAAW,EAAE,QAAgB,EAAE,EAAE;IACxD,IAAI;QACF,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAA;QAExB,OAAO,GAAG,CAAC,QAAQ,KAAK,QAAQ,IAAI,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAA;KACnD;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,KAAK,CAAA;KACb;AACH,CAAC,CAAA;AAEM,MAAM,SAAS,GAAG,CAAC,GAAW,EAAE,EAAE,CAAC,eAAe,CAAC,GAAG,EAAE,OAAO,CAAC,CAAA;AAA1D,QAAA,SAAS,aAAiD;AAEhE,MAAM,UAAU,GAAG,CAAC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