| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| import { isValidPackageName } from '../src/index'; |
|
|
| describe('Security: Package Name Validation', () => { |
| describe('isValidPackageName', () => { |
| |
| test('should accept valid scoped package', () => { |
| expect(isValidPackageName('@activepieces/piece-github')).toBe(true); |
| }); |
|
|
| test('should accept valid unscoped package', () => { |
| expect(isValidPackageName('express')).toBe(true); |
| expect(isValidPackageName('lodash')).toBe(true); |
| }); |
|
|
| test('should accept package with dots and hyphens', () => { |
| expect(isValidPackageName('@scope/package.name')).toBe(true); |
| expect(isValidPackageName('package-name')).toBe(true); |
| }); |
|
|
| |
| test('should reject semicolon injection', () => { |
| expect(isValidPackageName('express; touch /tmp/pwned #')).toBe(false); |
| }); |
|
|
| test('should reject pipe injection', () => { |
| expect(isValidPackageName('express | cat /etc/passwd')).toBe(false); |
| }); |
|
|
| test('should reject command substitution', () => { |
| expect(isValidPackageName('express$(whoami)')).toBe(false); |
| expect(isValidPackageName('express`id`')).toBe(false); |
| }); |
|
|
| test('should reject backtick injection', () => { |
| expect(isValidPackageName('express`rm -rf /`')).toBe(false); |
| }); |
|
|
| test('should reject newline injection', () => { |
| expect(isValidPackageName('express\nmalicious')).toBe(false); |
| }); |
|
|
| test('should reject null bytes', () => { |
| expect(isValidPackageName('express\x00rm')).toBe(false); |
| }); |
|
|
| |
| test('should reject empty string', () => { |
| expect(isValidPackageName('')).toBe(false); |
| }); |
|
|
| test('should reject overly long names (>214 chars)', () => { |
| const longName = 'a'.repeat(215); |
| expect(isValidPackageName(longName)).toBe(false); |
| }); |
|
|
| test('should reject spaces', () => { |
| expect(isValidPackageName('express express')).toBe(false); |
| }); |
|
|
| test('should reject special shell characters', () => { |
| expect(isValidPackageName('express&ls')).toBe(false); |
| expect(isValidPackageName('express&&whoami')).toBe(false); |
| expect(isValidPackageName('express||true')).toBe(false); |
| expect(isValidPackageName('express>file')).toBe(false); |
| expect(isValidPackageName('express<file')).toBe(false); |
| }); |
|
|
| |
| test('should accept valid scoped packages', () => { |
| expect(isValidPackageName('@babel/core')).toBe(true); |
| expect(isValidPackageName('@types/node')).toBe(true); |
| expect(isValidPackageName('@angular/router')).toBe(true); |
| }); |
|
|
| test('should accept valid unscoped packages', () => { |
| expect(isValidPackageName('react')).toBe(true); |
| expect(isValidPackageName('vue')).toBe(true); |
| expect(isValidPackageName('axios')).toBe(true); |
| expect(isValidPackageName('typescript')).toBe(true); |
| }); |
| }); |
| }); |
|
|
| describe('Security: Authentication Middleware', () => { |
| |
| |
|
|
| test('POST /sys/install should require authentication', () => { |
| |
| |
| |
| }); |
|
|
| test('POST /execute/action should require authentication', () => { |
| |
| |
| |
| }); |
|
|
| test('GET /pieces/:name should require authentication when dynamic loading needed', () => { |
| |
| |
| }); |
|
|
| test('GET /health should not require authentication', () => { |
| |
| }); |
|
|
| test('GET /pieces should not require authentication', () => { |
| |
| }); |
| }); |
|
|
| describe('Security: Command Injection Prevention', () => { |
| test('spawn() should be used instead of exec()', () => { |
| |
| |
| }); |
|
|
| test('npm commands should use argument arrays', () => { |
| |
| |
| }); |
| }); |
|
|