@shipfox/api-secrets 8.0.0 → 9.0.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/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +37 -0
- package/dist/core/identifier-policy.d.ts +4 -0
- package/dist/core/identifier-policy.d.ts.map +1 -0
- package/dist/core/identifier-policy.js +12 -0
- package/dist/core/identifier-policy.js.map +1 -0
- package/dist/core/store-validation.d.ts.map +1 -1
- package/dist/core/store-validation.js +2 -1
- package/dist/core/store-validation.js.map +1 -1
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/presentation/routes/warnings.d.ts.map +1 -1
- package/dist/presentation/routes/warnings.js +4 -3
- package/dist/presentation/routes/warnings.js.map +1 -1
- package/dist/tsconfig.test.tsbuildinfo +1 -1
- package/package.json +15 -16
- package/src/core/identifier-policy.test.ts +25 -0
- package/src/core/identifier-policy.ts +13 -0
- package/src/core/store-validation.ts +2 -1
- package/src/index.ts +2 -2
- package/src/presentation/routes/warnings.ts +3 -6
- package/tsconfig.build.tsbuildinfo +1 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shipfox/api-secrets",
|
|
3
3
|
"license": "MIT",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "9.0.1",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/ShipfoxHQ/shipfox.git",
|
|
@@ -11,10 +11,6 @@
|
|
|
11
11
|
"type": "module",
|
|
12
12
|
"main": "dist/index.js",
|
|
13
13
|
"types": "dist/index.d.ts",
|
|
14
|
-
"imports": {
|
|
15
|
-
"#test/*": "./test/*",
|
|
16
|
-
"#*": "./dist/*"
|
|
17
|
-
},
|
|
18
14
|
"exports": {
|
|
19
15
|
".": {
|
|
20
16
|
"types": "./dist/index.d.ts",
|
|
@@ -28,17 +24,20 @@
|
|
|
28
24
|
"dependencies": {
|
|
29
25
|
"drizzle-orm": "^0.45.2",
|
|
30
26
|
"zod": "^4.4.3",
|
|
31
|
-
"@shipfox/api-auth-context": "
|
|
32
|
-
"@shipfox/api-projects-dto": "
|
|
33
|
-
"@shipfox/api-secrets-dto": "
|
|
34
|
-
"@shipfox/config": "1.2.
|
|
35
|
-
"@shipfox/inter-module": "0.2.
|
|
36
|
-
"@shipfox/node-drizzle": "0.3.
|
|
37
|
-
"@shipfox/node-fastify": "0.3.
|
|
38
|
-
"@shipfox/node-module": "0.
|
|
39
|
-
"@shipfox/node-opentelemetry": "0.6.
|
|
40
|
-
"@shipfox/node-outbox": "0.2.
|
|
41
|
-
"@shipfox/node-postgres": "0.4.
|
|
27
|
+
"@shipfox/api-auth-context": "9.0.1",
|
|
28
|
+
"@shipfox/api-projects-dto": "9.0.1",
|
|
29
|
+
"@shipfox/api-secrets-dto": "9.0.1",
|
|
30
|
+
"@shipfox/config": "1.2.3",
|
|
31
|
+
"@shipfox/inter-module": "0.2.1",
|
|
32
|
+
"@shipfox/node-drizzle": "0.3.3",
|
|
33
|
+
"@shipfox/node-fastify": "0.3.1",
|
|
34
|
+
"@shipfox/node-module": "1.0.0",
|
|
35
|
+
"@shipfox/node-opentelemetry": "0.6.1",
|
|
36
|
+
"@shipfox/node-outbox": "0.2.5",
|
|
37
|
+
"@shipfox/node-postgres": "0.4.3"
|
|
38
|
+
},
|
|
39
|
+
"imports": {
|
|
40
|
+
"#*": "./dist/*"
|
|
42
41
|
},
|
|
43
42
|
"scripts": {
|
|
44
43
|
"build": "shipfox-swc",
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {describe, expect, it} from '@shipfox/vitest/vi';
|
|
2
|
+
import {isSensitiveSecretName, isShortSecretValue, isSystemNamespace} from './identifier-policy.js';
|
|
3
|
+
|
|
4
|
+
describe('isSystemNamespace', () => {
|
|
5
|
+
it('classifies system and user namespaces', () => {
|
|
6
|
+
expect(isSystemNamespace('system/agent/x')).toBe(true);
|
|
7
|
+
expect(isSystemNamespace('')).toBe(false);
|
|
8
|
+
expect(isSystemNamespace('REGION')).toBe(false);
|
|
9
|
+
});
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
describe('isSensitiveSecretName', () => {
|
|
13
|
+
it('classifies sensitive names', () => {
|
|
14
|
+
expect(isSensitiveSecretName('API_TOKEN')).toBe(true);
|
|
15
|
+
expect(isSensitiveSecretName('PASSWORD')).toBe(true);
|
|
16
|
+
expect(isSensitiveSecretName('REGION')).toBe(false);
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
describe('isShortSecretValue', () => {
|
|
21
|
+
it('classifies short secret values', () => {
|
|
22
|
+
expect(isShortSecretValue('short', 12)).toBe(true);
|
|
23
|
+
expect(isShortSecretValue('long-enough-value', 12)).toBe(false);
|
|
24
|
+
});
|
|
25
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import {SENSITIVE_NAME_PATTERNS, SYSTEM_NAMESPACE_PREFIX} from '@shipfox/api-secrets-dto';
|
|
2
|
+
|
|
3
|
+
export function isSystemNamespace(namespace: string): boolean {
|
|
4
|
+
return namespace.startsWith(SYSTEM_NAMESPACE_PREFIX);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function isSensitiveSecretName(key: string): boolean {
|
|
8
|
+
return SENSITIVE_NAME_PATTERNS.some((pattern) => key.includes(pattern));
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function isShortSecretValue(value: string, threshold: number): boolean {
|
|
12
|
+
return value.length > 0 && value.length < threshold;
|
|
13
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {namespaceSchema, secretKeySchema} from '@shipfox/api-secrets-dto';
|
|
2
2
|
import {config, MAX_VALUE_BYTES} from '#config.js';
|
|
3
3
|
import {countWorkspaceEntries, type Tx} from '#db/index.js';
|
|
4
4
|
import {
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
SecretValueTooLargeError,
|
|
8
8
|
WorkspaceSecretCapExceededError,
|
|
9
9
|
} from './errors.js';
|
|
10
|
+
import {isSystemNamespace} from './identifier-policy.js';
|
|
10
11
|
|
|
11
12
|
export function validateNamespace(namespace: string): void {
|
|
12
13
|
if (namespaceSchema.safeParse(namespace).success) return;
|
package/src/index.ts
CHANGED
|
@@ -45,7 +45,7 @@ export {
|
|
|
45
45
|
export function createSecretsModule(projects: ProjectsModuleClient): ShipfoxModule {
|
|
46
46
|
return {
|
|
47
47
|
name: 'secrets',
|
|
48
|
-
database: {db, migrationsPath},
|
|
48
|
+
database: {db, migrationsPath, databaseNamespace: 'secrets'},
|
|
49
49
|
routes: createSecretsRoutes(projects),
|
|
50
50
|
e2eRoutes: [secretsE2eRoutes],
|
|
51
51
|
metrics: registerSecretsServiceMetrics,
|
|
@@ -57,5 +57,5 @@ export function createSecretsModule(projects: ProjectsModuleClient): ShipfoxModu
|
|
|
57
57
|
// Migration setup imports this declaration only for the owned database metadata.
|
|
58
58
|
export const secretsModule: ShipfoxModule = {
|
|
59
59
|
name: 'secrets',
|
|
60
|
-
database: {db, migrationsPath},
|
|
60
|
+
database: {db, migrationsPath, databaseNamespace: 'secrets'},
|
|
61
61
|
};
|
|
@@ -2,22 +2,19 @@ import {
|
|
|
2
2
|
SENSITIVE_VARIABLE_NAME_WARNING,
|
|
3
3
|
type SecretWriteWarningDto,
|
|
4
4
|
SHORT_SECRET_VALUE_WARNING,
|
|
5
|
-
shouldWarnSensitiveVariableName,
|
|
6
|
-
shouldWarnShortSecretValue,
|
|
7
5
|
} from '@shipfox/api-secrets-dto';
|
|
8
6
|
import {config} from '#config.js';
|
|
7
|
+
import {isSensitiveSecretName, isShortSecretValue} from '#core/identifier-policy.js';
|
|
9
8
|
import type {ManagementEntry} from '#core/index.js';
|
|
10
9
|
|
|
11
10
|
export function secretWarnings(entries: ManagementEntry[]): SecretWriteWarningDto[] {
|
|
12
11
|
return entries
|
|
13
|
-
.filter((entry) =>
|
|
14
|
-
shouldWarnShortSecretValue(entry.value, config.SECRETS_SHORT_VALUE_WARN_LENGTH),
|
|
15
|
-
)
|
|
12
|
+
.filter((entry) => isShortSecretValue(entry.value, config.SECRETS_SHORT_VALUE_WARN_LENGTH))
|
|
16
13
|
.map((entry) => ({code: SHORT_SECRET_VALUE_WARNING, key: entry.key}));
|
|
17
14
|
}
|
|
18
15
|
|
|
19
16
|
export function variableWarnings(entries: ManagementEntry[]): SecretWriteWarningDto[] {
|
|
20
17
|
return entries
|
|
21
|
-
.filter((entry) =>
|
|
18
|
+
.filter((entry) => isSensitiveSecretName(entry.key))
|
|
22
19
|
.map((entry) => ({code: SENSITIVE_VARIABLE_NAME_WARNING, key: entry.key}));
|
|
23
20
|
}
|