@secretlint/secretlint-rule-databricks 0.0.1 → 11.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.
package/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2026 azu
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ SOFTWARE.
package/README.md CHANGED
@@ -1,45 +1,69 @@
1
1
  # @secretlint/secretlint-rule-databricks
2
2
 
3
- ## ⚠️ IMPORTANT NOTICE ⚠️
3
+ A rule for detecting [Databricks personal access tokens](https://docs.databricks.com/aws/en/dev-tools/auth/pat) in your code.
4
4
 
5
- **This package is created solely for the purpose of setting up OIDC (OpenID Connect) trusted publishing with npm.**
5
+ ## Install
6
6
 
7
- This is **NOT** a functional package and contains **NO** code or functionality beyond the OIDC setup configuration.
7
+ Install with [npm](https://www.npmjs.com/):
8
8
 
9
- ## Purpose
9
+ npm install @secretlint/secretlint-rule-databricks
10
10
 
11
- This package exists to:
12
- 1. Configure OIDC trusted publishing for the package name `@secretlint/secretlint-rule-databricks`
13
- 2. Enable secure, token-less publishing from CI/CD workflows
14
- 3. Establish provenance for packages published under this name
11
+ ## Usage
15
12
 
16
- ## What is OIDC Trusted Publishing?
13
+ Via `.secretlintrc.json`(Recommended)
17
14
 
18
- OIDC trusted publishing allows package maintainers to publish packages directly from their CI/CD workflows without needing to manage npm access tokens. Instead, it uses OpenID Connect to establish trust between the CI/CD provider (like GitHub Actions) and npm.
15
+ ```json
16
+ {
17
+ "rules": [
18
+ {
19
+ "id": "@secretlint/secretlint-rule-databricks"
20
+ }
21
+ ]
22
+ }
23
+ ```
19
24
 
20
- ## Setup Instructions
25
+ ## MessageIDs
21
26
 
22
- To properly configure OIDC trusted publishing for this package:
27
+ ### DATABRICKS_PERSONAL_ACCESS_TOKEN
23
28
 
24
- 1. Go to [npmjs.com](https://www.npmjs.com/) and navigate to your package settings
25
- 2. Configure the trusted publisher (e.g., GitHub Actions)
26
- 3. Specify the repository and workflow that should be allowed to publish
27
- 4. Use the configured workflow to publish your actual package
29
+ Databricks personal access token is detected.
28
30
 
29
- ## DO NOT USE THIS PACKAGE
31
+ Databricks personal access tokens start with the literal prefix `dapi`, followed by a 32-character hexadecimal string, with an optional `-<digit>` suffix. The rule matches hex characters case-insensitively.
30
32
 
31
- This package is a placeholder for OIDC configuration only. It:
32
- - Contains no executable code
33
- - Provides no functionality
34
- - Should not be installed as a dependency
35
- - Exists only for administrative purposes
33
+ **NG** examples:
36
34
 
37
- ## More Information
35
+ ```
36
+ DATABRICKS_TOKEN=dapi1234567890ABCDEF1234567890ABCDEF
37
+ token: "dapi0123456789ABCDEF0123456789ABCDEF-3"
38
+ ```
38
39
 
39
- For more details about npm's trusted publishing feature, see:
40
- - [npm Trusted Publishing Documentation](https://docs.npmjs.com/generating-provenance-statements)
41
- - [GitHub Actions OIDC Documentation](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect)
40
+ ## Options
42
41
 
43
- ---
42
+ - `allows: string[]`
43
+ - Allows a list of [RegExp-like String](https://github.com/textlint/regexp-string-matcher#regexp-like-string)
44
44
 
45
- **Maintained for OIDC setup purposes only**
45
+ ## Changelog
46
+
47
+ See [Releases page](https://github.com/secretlint/secretlint/releases).
48
+
49
+ ## Running tests
50
+
51
+ Install devDependencies and Run `npm test`:
52
+
53
+ npm test
54
+
55
+ ## Contributing
56
+
57
+ Pull requests and stars are always welcome.
58
+
59
+ For bugs and feature requests, [please create an issue](https://github.com/secretlint/secretlint/issues).
60
+
61
+ 1. Fork it!
62
+ 2. Create your feature branch: `git checkout -b my-new-feature`
63
+ 3. Commit your changes: `git commit -am 'Add some feature'`
64
+ 4. Push to the branch: `git push origin my-new-feature`
65
+ 5. Submit a pull request :D
66
+
67
+ ## License
68
+
69
+ MIT © azu
@@ -0,0 +1,16 @@
1
+ import type { SecretLintRuleCreator } from "@secretlint/types";
2
+ export declare const messages: {
3
+ DATABRICKS_PERSONAL_ACCESS_TOKEN: {
4
+ en: (props: {
5
+ ID: string;
6
+ }) => string;
7
+ ja: (props: {
8
+ ID: string;
9
+ }) => string;
10
+ };
11
+ };
12
+ export type Options = {
13
+ allows?: string[];
14
+ };
15
+ export declare const creator: SecretLintRuleCreator<Options>;
16
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAwB,MAAM,mBAAmB,CAAC;AAGrF,eAAO,MAAM,QAAQ;;oBAED;YAAE,EAAE,EAAE,MAAM,CAAA;SAAE;oBACd;YAAE,EAAE,EAAE,MAAM,CAAA;SAAE;;CAEjC,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG;IAClB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACrB,CAAC;AAEF,eAAO,MAAM,OAAO,EAAE,qBAAqB,CAAC,OAAO,CA8ClD,CAAC"}
@@ -0,0 +1,55 @@
1
+ import { matchPatterns } from "@textlint/regexp-string-matcher";
2
+ export const messages = {
3
+ DATABRICKS_PERSONAL_ACCESS_TOKEN: {
4
+ en: (props) => `found Databricks personal access token: ${props.ID}`,
5
+ ja: (props) => `Databricks personal access token: ${props.ID} がみつかりました`,
6
+ },
7
+ };
8
+ export const creator = {
9
+ messages,
10
+ meta: {
11
+ id: "@secretlint/secretlint-rule-databricks",
12
+ recommended: true,
13
+ type: "scanner",
14
+ supportedContentTypes: ["text"],
15
+ docs: {
16
+ url: "https://github.com/secretlint/secretlint/blob/master/packages/%40secretlint/secretlint-rule-databricks/README.md",
17
+ },
18
+ },
19
+ create(context, options) {
20
+ const t = context.createTranslator(messages);
21
+ const normalizedOptions = {
22
+ allows: options?.allows ?? [],
23
+ };
24
+ return {
25
+ file(source) {
26
+ // Databricks personal access tokens:
27
+ // - Prefix: `dapi`
28
+ // - Body: 32 hexadecimal characters (Databricks issues lowercase,
29
+ // but match case-insensitively to be lenient)
30
+ // - Optional suffix: `-<single digit>`
31
+ // Reference:
32
+ // - https://docs.databricks.com/aws/en/dev-tools/auth/pat
33
+ // - https://docs.github.com/en/code-security/secret-scanning/secret-scanning-patterns
34
+ const pattern = /(?<!\p{L})dapi[A-Fa-f0-9]{32}(?:-[0-9])?(?![A-Fa-f0-9])/gu;
35
+ const matches = source.content.matchAll(pattern);
36
+ for (const match of matches) {
37
+ const index = match.index ?? 0;
38
+ const matchString = match[0] ?? "";
39
+ const allowedResults = matchPatterns(matchString, normalizedOptions.allows);
40
+ if (allowedResults.length > 0) {
41
+ continue;
42
+ }
43
+ const range = [index, index + matchString.length];
44
+ context.report({
45
+ message: t("DATABRICKS_PERSONAL_ACCESS_TOKEN", {
46
+ ID: matchString,
47
+ }),
48
+ range,
49
+ });
50
+ }
51
+ },
52
+ };
53
+ },
54
+ };
55
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot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c,GAAG,aAAa,CAAC,WAAW,EAAE,iBAAiB,CAAC,MAAM,CAAC,CAAC;oBAC5E,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;wBAC5B,SAAS;oBACb,CAAC;oBACD,MAAM,KAAK,GAAG,CAAC,KAAK,EAAE,KAAK,GAAG,WAAW,CAAC,MAAM,CAAU,CAAC;oBAC3D,OAAO,CAAC,MAAM,CAAC;wBACX,OAAO,EAAE,CAAC,CAAC,kCAAkC,EAAE;4BAC3C,EAAE,EAAE,WAAW;yBAClB,CAAC;wBACF,KAAK;qBACR,CAAC,CAAC;gBACP,CAAC;YACL,CAAC;SACJ,CAAC;IACN,CAAC;CACJ,CAAC"}
@@ -0,0 +1 @@
1
+ {"root":["../src/index.ts"],"version":"5.9.2"}
package/package.json CHANGED
@@ -1,10 +1,71 @@
1
1
  {
2
2
  "name": "@secretlint/secretlint-rule-databricks",
3
- "version": "0.0.1",
4
- "description": "OIDC trusted publishing setup package for @secretlint/secretlint-rule-databricks",
3
+ "version": "11.7.1",
4
+ "description": "A secretlint rule for detecting Databricks personal access tokens",
5
5
  "keywords": [
6
- "oidc",
7
- "trusted-publishing",
8
- "setup"
9
- ]
10
- }
6
+ "secretlint",
7
+ "rule",
8
+ "databricks",
9
+ "token",
10
+ "security"
11
+ ],
12
+ "homepage": "https://github.com/secretlint/secretlint/tree/master/packages/@secretlint/secretlint-rule-databricks/",
13
+ "bugs": {
14
+ "url": "https://github.com/secretlint/secretlint/issues"
15
+ },
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "https://github.com/secretlint/secretlint.git"
19
+ },
20
+ "license": "MIT",
21
+ "author": "azu",
22
+ "type": "module",
23
+ "exports": {
24
+ ".": {
25
+ "import": {
26
+ "types": "./module/index.d.ts",
27
+ "default": "./module/index.js"
28
+ },
29
+ "default": "./module/index.js"
30
+ },
31
+ "./package.json": "./package.json"
32
+ },
33
+ "main": "./module/index.js",
34
+ "types": "./module/index.d.ts",
35
+ "files": [
36
+ "bin/",
37
+ "module/",
38
+ "src/"
39
+ ],
40
+ "prettier": {
41
+ "printWidth": 120,
42
+ "singleQuote": false,
43
+ "tabWidth": 4
44
+ },
45
+ "dependencies": {
46
+ "@textlint/regexp-string-matcher": "^2.0.2",
47
+ "@secretlint/types": "11.7.1"
48
+ },
49
+ "devDependencies": {
50
+ "@types/node": "^24.12.2",
51
+ "prettier": "^2.8.8",
52
+ "tsx": "^4.21.0",
53
+ "typescript": "^5.8.3",
54
+ "@secretlint/tester": "11.7.1"
55
+ },
56
+ "engines": {
57
+ "node": ">=20.0.0"
58
+ },
59
+ "publishConfig": {
60
+ "access": "public"
61
+ },
62
+ "scripts": {
63
+ "build": "tsc --build",
64
+ "clean": "tsc --build --clean",
65
+ "prettier": "prettier --write \"**/*.{js,jsx,ts,tsx,css}\"",
66
+ "prepublish": "npm run --if-present build",
67
+ "test": "node --import tsx --test test/index.test.ts",
68
+ "updateSnapshot": "UPDATE_SNAPSHOT=1 npm test",
69
+ "watch": "tsc --build --watch"
70
+ }
71
+ }
package/src/index.ts ADDED
@@ -0,0 +1,61 @@
1
+ import type { SecretLintRuleCreator, SecretLintSourceCode } from "@secretlint/types";
2
+ import { matchPatterns } from "@textlint/regexp-string-matcher";
3
+
4
+ export const messages = {
5
+ DATABRICKS_PERSONAL_ACCESS_TOKEN: {
6
+ en: (props: { ID: string }) => `found Databricks personal access token: ${props.ID}`,
7
+ ja: (props: { ID: string }) => `Databricks personal access token: ${props.ID} がみつかりました`,
8
+ },
9
+ };
10
+
11
+ export type Options = {
12
+ allows?: string[];
13
+ };
14
+
15
+ export const creator: SecretLintRuleCreator<Options> = {
16
+ messages,
17
+ meta: {
18
+ id: "@secretlint/secretlint-rule-databricks",
19
+ recommended: true,
20
+ type: "scanner",
21
+ supportedContentTypes: ["text"],
22
+ docs: {
23
+ url: "https://github.com/secretlint/secretlint/blob/master/packages/%40secretlint/secretlint-rule-databricks/README.md",
24
+ },
25
+ },
26
+ create(context, options) {
27
+ const t = context.createTranslator(messages);
28
+ const normalizedOptions = {
29
+ allows: options?.allows ?? [],
30
+ };
31
+ return {
32
+ file(source: SecretLintSourceCode) {
33
+ // Databricks personal access tokens:
34
+ // - Prefix: `dapi`
35
+ // - Body: 32 hexadecimal characters (Databricks issues lowercase,
36
+ // but match case-insensitively to be lenient)
37
+ // - Optional suffix: `-<single digit>`
38
+ // Reference:
39
+ // - https://docs.databricks.com/aws/en/dev-tools/auth/pat
40
+ // - https://docs.github.com/en/code-security/secret-scanning/secret-scanning-patterns
41
+ const pattern = /(?<!\p{L})dapi[A-Fa-f0-9]{32}(?:-[0-9])?(?![A-Fa-f0-9])/gu;
42
+ const matches = source.content.matchAll(pattern);
43
+ for (const match of matches) {
44
+ const index = match.index ?? 0;
45
+ const matchString = match[0] ?? "";
46
+ const allowedResults = matchPatterns(matchString, normalizedOptions.allows);
47
+ if (allowedResults.length > 0) {
48
+ continue;
49
+ }
50
+ const range = [index, index + matchString.length] as const;
51
+ context.report({
52
+ message: t("DATABRICKS_PERSONAL_ACCESS_TOKEN", {
53
+ ID: matchString,
54
+ }),
55
+ range,
56
+ });
57
+ }
58
+ },
59
+ };
60
+ },
61
+ };