Skip to content

Commit 9fbe4a8

Browse files
author
jovanSAPFIONEER
committed
Fix Snyk: replace hardcoded salt with random salt in DataEncryptor
1 parent c46e0be commit 9fbe4a8

File tree

4 files changed

+25
-11
lines changed

4 files changed

+25
-11
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "network-ai",
3-
"version": "3.0.0",
3+
"version": "3.0.1",
44
"description": "AI agent orchestration framework for TypeScript/Node.js - plug-and-play multi-agent coordination with 12 frameworks (LangChain, AutoGen, CrewAI, OpenAI Assistants, LlamaIndex, Semantic Kernel, Haystack, DSPy, Agno, MCP, OpenClaw). Built-in security, swarm intelligence, and agentic workflow patterns.",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

security.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -584,10 +584,22 @@ export class SecureAuditLogger {
584584
export class DataEncryptor {
585585
private key: Buffer;
586586
private algorithm = 'aes-256-gcm' as const;
587+
private salt: Buffer;
587588

588-
constructor(encryptionKey: string) {
589-
// Derive a proper key from the provided key
590-
this.key = scryptSync(encryptionKey, 'swarm-salt', 32);
589+
constructor(encryptionKey: string, salt?: string | Buffer) {
590+
// Use provided salt or generate a random one
591+
this.salt = salt
592+
? (typeof salt === 'string' ? Buffer.from(salt, 'hex') : salt)
593+
: randomBytes(16);
594+
// Derive a proper key from the provided key with unique salt
595+
this.key = scryptSync(encryptionKey, this.salt, 32);
596+
}
597+
598+
/**
599+
* Get the salt (needed to recreate the same encryptor for decryption)
600+
*/
601+
getSalt(): string {
602+
return this.salt.toString('hex');
591603
}
592604

593605
/**

swarm-blackboard.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Swarm Blackboard
2-
Last Updated: 2026-02-15T13:33:05.021Z
2+
Last Updated: 2026-02-15T14:46:17.062Z
33

44
## Active Tasks
55
| TaskID | Agent | Status | Started | Description |
@@ -18,7 +18,7 @@ Last Updated: 2026-02-15T13:33:05.021Z
1818
"status": "complete"
1919
},
2020
"sourceAgent": "code_writer",
21-
"timestamp": "2026-02-15T13:33:05.012Z",
21+
"timestamp": "2026-02-15T14:46:17.046Z",
2222
"ttl": null
2323
}
2424

@@ -34,7 +34,7 @@ Last Updated: 2026-02-15T13:33:05.021Z
3434
"reviewer": "code_reviewer"
3535
},
3636
"sourceAgent": "code_reviewer",
37-
"timestamp": "2026-02-15T13:33:05.016Z",
37+
"timestamp": "2026-02-15T14:46:17.051Z",
3838
"ttl": null
3939
}
4040

@@ -49,7 +49,7 @@ Last Updated: 2026-02-15T13:33:05.021Z
4949
"duration": 3200
5050
},
5151
"sourceAgent": "test_runner",
52-
"timestamp": "2026-02-15T13:33:05.017Z",
52+
"timestamp": "2026-02-15T14:46:17.057Z",
5353
"ttl": null
5454
}
5555

@@ -60,7 +60,7 @@ Last Updated: 2026-02-15T13:33:05.021Z
6060
"replicas": 3
6161
},
6262
"sourceAgent": "devops_agent",
63-
"timestamp": "2026-02-15T13:33:05.021Z",
63+
"timestamp": "2026-02-15T14:46:17.062Z",
6464
"ttl": null
6565
}
6666

test-security.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,9 @@ function fail(test: string, error?: string) {
6262
async function testSecureTokenManager() {
6363
header('TEST 1: Secure Token Manager');
6464

65+
// Intentional test-only values -- not real secrets
6566
const tokenManager = new SecureTokenManager({
66-
tokenSecret: 'test-secret-key-for-testing-only',
67+
tokenSecret: 'test-secret-key-for-testing-only', // nosemgrep, snyk:ignore
6768
maxTokenAge: 5000, // 5 seconds for testing
6869
});
6970

@@ -529,7 +530,8 @@ async function testSecureSwarmGateway() {
529530

530531
// Test: Data encryption through gateway
531532
log('\n [SEC] Testing gateway encryption...', 'blue');
532-
const sensitiveData = { apiKey: 'sk-1234567890', password: 'secret123' };
533+
// Intentional fake test data -- not real credentials
534+
const sensitiveData = { apiKey: 'sk-1234567890', password: 'secret123' }; // nosemgrep, snyk:ignore
533535
const encrypted = gateway.encryptSensitiveData(sensitiveData);
534536
const decrypted = gateway.decryptSensitiveData<typeof sensitiveData>(encrypted);
535537

0 commit comments

Comments
 (0)