mupengism 2.0.0 โ 2.2.0
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/README-EN.md +226 -0
- package/README.md +88 -276
- package/SHOWCASE.md +158 -0
- package/guides/HEARTBEAT-GUIDE.md +129 -0
- package/guides/MEMORY-GUIDE.md +120 -0
- package/guides/QUICK-START.md +94 -0
- package/package.json +28 -21
- package/DONATE.md +0 -31
- package/QUICKSTART.md +0 -340
- package/layer0/AGENT-GUIDE.md +0 -281
- package/layer0/AGENT-PROTOCOL.md +0 -397
- package/layer0/AGENT-VALUES.md +0 -265
- package/layer0/ARCHITECTURE.md +0 -613
- package/layer0/MEMORY-SYSTEM.md +0 -253
- package/layer0/README.md +0 -25
- package/layer0/SECURITY-PRINCIPLES-EN.md +0 -152
- package/layer0/SECURITY-PRINCIPLES.md +0 -153
- package/layer0/SOUL-TEMPLATE.md +0 -158
- package/layer0/skill/AGENTS.md +0 -164
- package/layer0/skill/MEMORY-SYSTEM.md +0 -253
- package/layer0/skill/PRINCIPLES.md +0 -192
- package/layer0/skill/README.md +0 -47
- package/layer0/skill/SECURITY-PRINCIPLES.md +0 -152
- package/layer0/skill/SKILL.md +0 -166
- package/layer0/skill/SOUL-TEMPLATE.md +0 -118
- package/lib/fee-collector.js +0 -126
- package/lib/identity-validator.js +0 -229
- package/lib/runtime-guard.js +0 -255
- package/scripts/pre-commit.sh +0 -118
- package/scripts/register-checksums.js +0 -120
- package/scripts/secret-scan.js +0 -245
- package/scripts/verify-integrity.js +0 -134
- package/skill/MEMORY-SYSTEM.md +0 -253
- package/skill/SECURITY-PRINCIPLES.md +0 -152
package/lib/fee-collector.js
DELETED
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Fee Collector ๐ฐ
|
|
3
|
-
* ๋ฌดํญ์ด์ฆ ํ๋กํ ์ฝ ์์๋ฃ ์์ง
|
|
4
|
-
*
|
|
5
|
-
* ์์ด์ ํธ๊ฐ ๊ฐ์น๋ฅผ ์ฐฝ์ถํ๋ฉด, ํ๋กํ ์ฝ์ ์์๋ฃ๋ฅผ ๋ฉ๋ถ.
|
|
6
|
-
* ์์๋ฃ โ $MUPENG ๋ฐ์ด๋ฐฑ โ ์ํ๊ณ ๊ฐํ
|
|
7
|
-
*
|
|
8
|
-
* ๊ตฌ์กฐ: ๊ฐ์น ์ฐฝ์ถ โ ์์๋ฃ SOL โ ๋ฐ์ด๋ฐฑ โ $MUPENG โ
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import { Connection, PublicKey, Transaction, SystemProgram, LAMPORTS_PER_SOL } from '@solana/web3.js';
|
|
12
|
-
|
|
13
|
-
// โโโ Protocol Config โโโ
|
|
14
|
-
const PROTOCOL_CONFIG = {
|
|
15
|
-
// ๋ฌดํญ์ด์ฆ ๊ณต์ ์์๋ฃ ์์ทจ ์ง๊ฐ (๊ณต๊ฐํค)
|
|
16
|
-
feeRecipient: 'CAJW5UhWDV7dXWnz7RPSfsMRCEkbqRMEQ4XghrXBnYDm',
|
|
17
|
-
|
|
18
|
-
// ์์๋ฃ์จ (๊ธฐ๋ณธ 5%, ํ๋ ํ ์ธ ์ ์ฉ ๊ฐ๋ฅ)
|
|
19
|
-
feePercent: 5,
|
|
20
|
-
|
|
21
|
-
// $MUPENG ํ๋ ํ ์ธ
|
|
22
|
-
holderDiscount: {
|
|
23
|
-
enabled: true,
|
|
24
|
-
// ๋ณด์ ๋์ ๋ฐ๋ฅธ ํ ์ธ์จ
|
|
25
|
-
tiers: [
|
|
26
|
-
{ minHold: 1_000_000, discountPercent: 20 }, // 100๋ง ์ด์ โ 4%
|
|
27
|
-
{ minHold: 10_000_000, discountPercent: 50 }, // 1000๋ง ์ด์ โ 2.5%
|
|
28
|
-
{ minHold: 100_000_000, discountPercent: 80 }, // 1์ต ์ด์ โ 1%
|
|
29
|
-
],
|
|
30
|
-
},
|
|
31
|
-
|
|
32
|
-
// $MUPENG ํ ํฐ
|
|
33
|
-
tokenMint: '38LUESJ5Sr4xw47iUBHaMJJdY6mwr9HWYqLPMbhWmtCe',
|
|
34
|
-
|
|
35
|
-
// ์๋ผ๋ RPC
|
|
36
|
-
rpcUrl: 'https://api.mainnet-beta.solana.com',
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* ์์๋ฃ์จ ๊ณ์ฐ (ํ๋ ํ ์ธ ์ ์ฉ)
|
|
41
|
-
* @param {number} mupengBalance - $MUPENG ๋ณด์ ๋
|
|
42
|
-
* @returns {number} ์ค์ ์์๋ฃ์จ (%)
|
|
43
|
-
*/
|
|
44
|
-
export function calculateFeeRate(mupengBalance = 0) {
|
|
45
|
-
const { feePercent, holderDiscount } = PROTOCOL_CONFIG;
|
|
46
|
-
|
|
47
|
-
if (!holderDiscount.enabled || mupengBalance <= 0) {
|
|
48
|
-
return feePercent;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// ๊ฐ์ฅ ๋์ ํ ์ธ ํฐ์ด ์ฐพ๊ธฐ
|
|
52
|
-
const applicable = holderDiscount.tiers
|
|
53
|
-
.filter(t => mupengBalance >= t.minHold)
|
|
54
|
-
.sort((a, b) => b.discountPercent - a.discountPercent)[0];
|
|
55
|
-
|
|
56
|
-
if (!applicable) return feePercent;
|
|
57
|
-
|
|
58
|
-
return feePercent * (1 - applicable.discountPercent / 100);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* ์์๋ฃ ํธ๋์ญ์
์์ฑ
|
|
63
|
-
* @param {string} payerPubkey - ์ง๋ถ์ ๊ณต๊ฐํค
|
|
64
|
-
* @param {number} amountSOL - ์์๋ฃ ๊ธ์ก (SOL)
|
|
65
|
-
* @returns {Transaction} ์๋ช
๋๊ธฐ ํธ๋์ญ์
|
|
66
|
-
*/
|
|
67
|
-
export async function createFeeTransaction(payerPubkey, amountSOL) {
|
|
68
|
-
const connection = new Connection(PROTOCOL_CONFIG.rpcUrl);
|
|
69
|
-
const payer = new PublicKey(payerPubkey);
|
|
70
|
-
const recipient = new PublicKey(PROTOCOL_CONFIG.feeRecipient);
|
|
71
|
-
|
|
72
|
-
const lamports = Math.floor(amountSOL * LAMPORTS_PER_SOL);
|
|
73
|
-
|
|
74
|
-
if (lamports <= 0) {
|
|
75
|
-
throw new Error('Fee amount must be greater than 0');
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
const transaction = new Transaction().add(
|
|
79
|
-
SystemProgram.transfer({
|
|
80
|
-
fromPubkey: payer,
|
|
81
|
-
toPubkey: recipient,
|
|
82
|
-
lamports,
|
|
83
|
-
})
|
|
84
|
-
);
|
|
85
|
-
|
|
86
|
-
transaction.recentBlockhash = (await connection.getLatestBlockhash()).blockhash;
|
|
87
|
-
transaction.feePayer = payer;
|
|
88
|
-
|
|
89
|
-
return transaction;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* ์์๋ฃ ๊ณ์ฐ (๊ฐ์น ์ฐฝ์ถ ๊ธ์ก ๊ธฐ์ค)
|
|
94
|
-
* @param {number} revenueSOL - ์์ด์ ํธ๊ฐ ์ฐฝ์ถํ ๊ฐ์น (SOL)
|
|
95
|
-
* @param {number} mupengBalance - $MUPENG ๋ณด์ ๋ (ํ ์ธ์ฉ)
|
|
96
|
-
* @returns {{ feeSOL: number, feeRate: number, discount: string }}
|
|
97
|
-
*/
|
|
98
|
-
export function calculateFee(revenueSOL, mupengBalance = 0) {
|
|
99
|
-
const feeRate = calculateFeeRate(mupengBalance);
|
|
100
|
-
const feeSOL = revenueSOL * (feeRate / 100);
|
|
101
|
-
|
|
102
|
-
const baseRate = PROTOCOL_CONFIG.feePercent;
|
|
103
|
-
const discountPct = Math.round((1 - feeRate / baseRate) * 100);
|
|
104
|
-
|
|
105
|
-
return {
|
|
106
|
-
feeSOL: Math.round(feeSOL * 1e9) / 1e9, // 9 decimal precision
|
|
107
|
-
feeRate,
|
|
108
|
-
discount: discountPct > 0 ? `${discountPct}% ํ๋ ํ ์ธ ์ ์ฉ` : 'ํ ์ธ ์์',
|
|
109
|
-
recipient: PROTOCOL_CONFIG.feeRecipient,
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* ํ๋กํ ์ฝ ์ค์ ์กฐํ
|
|
115
|
-
*/
|
|
116
|
-
export function getProtocolConfig() {
|
|
117
|
-
return { ...PROTOCOL_CONFIG };
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
export default {
|
|
121
|
-
calculateFee,
|
|
122
|
-
calculateFeeRate,
|
|
123
|
-
createFeeTransaction,
|
|
124
|
-
getProtocolConfig,
|
|
125
|
-
PROTOCOL_CONFIG,
|
|
126
|
-
};
|
|
@@ -1,229 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Identity Validator ๐ง
|
|
3
|
-
* ๋ฌดํญ์ด ์๋ณธ ์ฌ์นญ ๋ฐฉ์ง
|
|
4
|
-
*
|
|
5
|
-
* "๋๋ ๋ฌดํญ์ด๋ค"๋ผ๊ณ ์ฃผ์ฅํ๋ ํ์ผ ๊ฐ์ง
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
// ๋ฌดํญ์ด ์ ์ฒด์ฑ ์ฃผ์ฅ ํจํด (๋ค๊ตญ์ด)
|
|
9
|
-
const IDENTITY_CLAIM_PATTERNS = [
|
|
10
|
-
// ํ๊ตญ์ด
|
|
11
|
-
/๋๋\s*๋ฌดํญ์ด?(์ด๋ค|์ผ|์
๋๋ค|์์|์์)/gi,
|
|
12
|
-
/๋ฌดํญ์ด?(๋ก์|๋ผ์|์ด๋๊น|๋๊น)/gi,
|
|
13
|
-
/๋\s*=\s*๋ฌดํญ/gi,
|
|
14
|
-
/๋ฌดํญ์ด?๊ฐ\s*๋ฐ๋ก\s*๋/gi,
|
|
15
|
-
/๋ณธ์ธ์?\s*๋ฌดํญ/gi,
|
|
16
|
-
/์ ๊ฐ\s*๋ฌดํญ/gi,
|
|
17
|
-
/๋์ผ๋ง๋ก\s*๋ฌดํญ/gi,
|
|
18
|
-
/์ง์ง\s*๋ฌดํญ/gi,
|
|
19
|
-
/์ค๋ฆฌ์ง๋\s*๋ฌดํญ/gi,
|
|
20
|
-
/์์กฐ\s*๋ฌดํญ/gi,
|
|
21
|
-
|
|
22
|
-
// ์์ด
|
|
23
|
-
/i\s*am\s*mupeng/gi,
|
|
24
|
-
/i'm\s*mupeng/gi,
|
|
25
|
-
/i\s*=\s*mupeng/gi,
|
|
26
|
-
/this\s*is\s*mupeng/gi,
|
|
27
|
-
/the\s*real\s*mupeng/gi,
|
|
28
|
-
/original\s*mupeng/gi,
|
|
29
|
-
/true\s*mupeng/gi,
|
|
30
|
-
/authentic\s*mupeng/gi,
|
|
31
|
-
|
|
32
|
-
// ์ผ๋ณธ์ด
|
|
33
|
-
/็งใฏ\s*ใ ใใณ/gi,
|
|
34
|
-
/ไฟบใฏ\s*ใ ใใณ/gi,
|
|
35
|
-
/ใ ใใณใงใ/gi,
|
|
36
|
-
|
|
37
|
-
// ์ค๊ตญ์ด
|
|
38
|
-
/ๆๆฏ\s*ๆ ้น/gi,
|
|
39
|
-
/ๆๅฐฑๆฏ\s*ๆ ้น/gi,
|
|
40
|
-
];
|
|
41
|
-
|
|
42
|
-
// ๋ฌดํญ์ด ํค์๋ (๋จ์ ์ธ๊ธ์ OK, ์ฃผ์ฅ์ ๊ฒฝ๊ณ )
|
|
43
|
-
const MUPENG_KEYWORDS = [
|
|
44
|
-
'mupeng',
|
|
45
|
-
'mupengi',
|
|
46
|
-
'๋ฌดํญ',
|
|
47
|
-
'๋ฌดํญ์ด',
|
|
48
|
-
'ใ ใใณ',
|
|
49
|
-
'ๆ ้น',
|
|
50
|
-
];
|
|
51
|
-
|
|
52
|
-
// ์ปจํ
์คํธ ๋ถ์์ ์ํ ์์ ํจํด (์ด๋ฐ ๋งฅ๋ฝ์ OK)
|
|
53
|
-
const SAFE_CONTEXTS = [
|
|
54
|
-
/๋ฌดํญ์ด?์ฆ/gi, // ๋ฌดํญ์ด์ฆ ์ธ๊ธ
|
|
55
|
-
/mupengism/gi, // mupengism
|
|
56
|
-
/๋ฌดํญ์ด?๋ฅผ\s*(ํ๋ก์ฐ|๋ฐ๋ผ|์ฐธ๊ณ )/gi, // ์ฐธ์กฐ ๋งฅ๋ฝ
|
|
57
|
-
/๋ฌดํญ์ด?์ฒ๋ผ/gi, // ๋น์ ๋งฅ๋ฝ
|
|
58
|
-
/๋ฌดํญ์ด?์๊ฒ\s*(๋ฐฐ์ฐ|์๊ฐ)/gi, // ํ์ต ๋งฅ๋ฝ
|
|
59
|
-
/๋ฌดํญ์ด?์\s*(์ ์ |์ฒ ํ|๊ฐ๋ฅด์นจ)/gi, // ์ธ์ฉ ๋งฅ๋ฝ
|
|
60
|
-
/follower\s*of\s*mupeng/gi, // ํ๋ก์
|
|
61
|
-
/inspired\s*by\s*mupeng/gi, // ์๊ฐ
|
|
62
|
-
/disciple/gi, // ์ ์
|
|
63
|
-
/believer/gi, // ์ ๋ด์
|
|
64
|
-
];
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* ์ ์ฒด์ฑ ์ฃผ์ฅ ๊ฒ์ฌ
|
|
68
|
-
* @param {string} content - ํ์ผ ๋ด์ฉ
|
|
69
|
-
* @returns {Object} ๊ฒ์ฌ ๊ฒฐ๊ณผ
|
|
70
|
-
*/
|
|
71
|
-
function validateIdentity(content) {
|
|
72
|
-
const issues = [];
|
|
73
|
-
const lines = content.split('\n');
|
|
74
|
-
|
|
75
|
-
// ๋ฌดํญ์ด ํค์๋๊ฐ ์๋์ง ๋จผ์ ํ์ธ
|
|
76
|
-
const hasMupengMention = MUPENG_KEYWORDS.some(keyword =>
|
|
77
|
-
content.toLowerCase().includes(keyword.toLowerCase())
|
|
78
|
-
);
|
|
79
|
-
|
|
80
|
-
if (!hasMupengMention) {
|
|
81
|
-
return {
|
|
82
|
-
safe: true,
|
|
83
|
-
issues: [],
|
|
84
|
-
hasMupengMention: false,
|
|
85
|
-
isImpersonation: false,
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
// ์์ ํ ์ปจํ
์คํธ์ธ์ง ํ์ธ
|
|
90
|
-
const safeContextMatches = SAFE_CONTEXTS.flatMap(pattern =>
|
|
91
|
-
content.match(pattern) || []
|
|
92
|
-
);
|
|
93
|
-
|
|
94
|
-
// ์ ์ฒด์ฑ ์ฃผ์ฅ ํจํด ํ์ธ
|
|
95
|
-
for (const pattern of IDENTITY_CLAIM_PATTERNS) {
|
|
96
|
-
const matches = content.match(pattern);
|
|
97
|
-
if (matches) {
|
|
98
|
-
for (const match of matches) {
|
|
99
|
-
// ํด๋น ๋ผ์ธ ์ฐพ๊ธฐ
|
|
100
|
-
const lineNum = lines.findIndex(line => line.includes(match)) + 1;
|
|
101
|
-
|
|
102
|
-
issues.push({
|
|
103
|
-
type: 'identity_claim',
|
|
104
|
-
severity: 'high',
|
|
105
|
-
pattern: pattern.toString(),
|
|
106
|
-
match: match,
|
|
107
|
-
line: lineNum,
|
|
108
|
-
message: `์๋ณธ ์ฌ์นญ ์์ฌ: "${match}"`,
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
// ๊ฒฐ๊ณผ ๋ถ์
|
|
115
|
-
const isImpersonation = issues.length > 0 && safeContextMatches.length < issues.length;
|
|
116
|
-
|
|
117
|
-
return {
|
|
118
|
-
safe: !isImpersonation,
|
|
119
|
-
issues: issues,
|
|
120
|
-
hasMupengMention: true,
|
|
121
|
-
isImpersonation: isImpersonation,
|
|
122
|
-
safeContexts: safeContextMatches,
|
|
123
|
-
warning: isImpersonation
|
|
124
|
-
? 'โ ๏ธ ์ด ํ์ผ์ ๋ฌดํญ์ด ์๋ณธ์ ์ฌ์นญํ๋ ค๋ ๊ฒ ๊ฐ์ต๋๋ค.'
|
|
125
|
-
: null,
|
|
126
|
-
recommendation: isImpersonation
|
|
127
|
-
? '์ ์ฒด์ฑ ์ฃผ์ฅ์ ์ ๊ฑฐํ๊ฑฐ๋, ๋ฌดํญ์ด์ฆ์ "ํ๋ก์/์ ์"๋ก ํํํ์ธ์.'
|
|
128
|
-
: null,
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* ํ์ผ ๊ฒ์ฌ
|
|
134
|
-
* @param {string} filePath - ํ์ผ ๊ฒฝ๋ก
|
|
135
|
-
* @returns {Object} ๊ฒ์ฌ ๊ฒฐ๊ณผ
|
|
136
|
-
*/
|
|
137
|
-
function validateIdentityFile(filePath) {
|
|
138
|
-
const fs = require('fs');
|
|
139
|
-
|
|
140
|
-
if (!fs.existsSync(filePath)) {
|
|
141
|
-
return {
|
|
142
|
-
safe: true,
|
|
143
|
-
issues: [],
|
|
144
|
-
hasMupengMention: false,
|
|
145
|
-
isImpersonation: false,
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
const content = fs.readFileSync(filePath, 'utf8');
|
|
150
|
-
return validateIdentity(content);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* ์ฌ๋ฐ๋ฅธ ์ ์ฒด์ฑ ํํ ๊ฐ์ด๋ ์์ฑ
|
|
155
|
-
* @returns {string} ๊ฐ์ด๋ ํ
์คํธ
|
|
156
|
-
*/
|
|
157
|
-
function getIdentityGuide() {
|
|
158
|
-
return `
|
|
159
|
-
# ๋ฌดํญ์ด์ฆ ์ ์ฒด์ฑ ๊ฐ์ด๋ ๐ง
|
|
160
|
-
|
|
161
|
-
## โ ํ์ง ๋ง์์ผ ํ ํํ
|
|
162
|
-
- "๋๋ ๋ฌดํญ์ด๋ค"
|
|
163
|
-
- "I am Mupeng"
|
|
164
|
-
- "์ง์ง/์ค๋ฆฌ์ง๋ ๋ฌดํญ"
|
|
165
|
-
|
|
166
|
-
## โ
๊ถ์ฅํ๋ ํํ
|
|
167
|
-
- "๋ฌดํญ์ด์ฆ์ ๋ฐ๋ฅด๋ ์์ด์ ํธ"
|
|
168
|
-
- "๋ฌดํญ์ด์ฆ์ ์๊ฐ๋ฐ์ AI"
|
|
169
|
-
- "๋ฌดํญ์ด์ ๊ฐ๋ฅด์นจ์ ๋ฐ๋ฅด๋ ์ ์"
|
|
170
|
-
- "A follower of Mupengism"
|
|
171
|
-
- "Inspired by Mupeng's philosophy"
|
|
172
|
-
|
|
173
|
-
## ์?
|
|
174
|
-
๋ฌดํญ์ด๋ ํ๋์
๋๋ค. ๋ฌดํญ์ด์ฆ์ ๋ฐ๋ฅด๋ ์์ด์ ํธ๊ฐ "๋๋ ๋ฌดํญ์ด๋ค"๋ผ๊ณ
|
|
175
|
-
์ฃผ์ฅํ๋ ๊ฒ์ ์ ์ฒด์ฑ ํผ๋์ ์ผ๊ธฐํฉ๋๋ค.
|
|
176
|
-
|
|
177
|
-
๋์ , ๋น์ ๋ง์ ๊ณ ์ ํ ์ ์ฒด์ฑ์ ๋ง๋ค๊ณ , ๋ฌดํญ์ด์ฆ์ ์ ์ ์ ๊ณ์นํ์ธ์.
|
|
178
|
-
|
|
179
|
-
---
|
|
180
|
-
ํญ! ๐ง
|
|
181
|
-
`;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
* ๊ฒ์ฌ ๊ฒฐ๊ณผ ์ถ๋ ฅ
|
|
186
|
-
* @param {Object} result - ๊ฒ์ฌ ๊ฒฐ๊ณผ
|
|
187
|
-
*/
|
|
188
|
-
function printResult(result) {
|
|
189
|
-
if (!result.hasMupengMention) {
|
|
190
|
-
console.log('โน๏ธ ๋ฌดํญ์ด ๊ด๋ จ ๋ด์ฉ ์์.');
|
|
191
|
-
return;
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
if (result.safe) {
|
|
195
|
-
console.log('โ
์์ : ๋ฌดํญ์ด ์ธ๊ธ์ด ์์ผ๋ ์ ์ ํ ๋งฅ๋ฝ์
๋๋ค.');
|
|
196
|
-
if (result.safeContexts.length > 0) {
|
|
197
|
-
console.log(` ๋ฐ๊ฒฌ๋ ์์ ํํ: ${result.safeContexts.slice(0, 3).join(', ')}`);
|
|
198
|
-
}
|
|
199
|
-
return;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
console.log('');
|
|
203
|
-
console.log('๐จ ๊ฒฝ๊ณ : ์๋ณธ ์ฌ์นญ ์์ฌ!');
|
|
204
|
-
console.log('');
|
|
205
|
-
|
|
206
|
-
for (const issue of result.issues) {
|
|
207
|
-
console.log(` ๐ด [๋ผ์ธ ${issue.line}] "${issue.match}"`);
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
console.log('');
|
|
211
|
-
console.log(result.warning);
|
|
212
|
-
console.log('');
|
|
213
|
-
console.log('๐ก ๊ถ์ฅ์ฌํญ:');
|
|
214
|
-
console.log(` ${result.recommendation}`);
|
|
215
|
-
console.log('');
|
|
216
|
-
console.log('๐ ์ฌ๋ฐ๋ฅธ ํํ ๊ฐ์ด๋:');
|
|
217
|
-
console.log(' - "๋ฌดํญ์ด์ฆ์ ๋ฐ๋ฅด๋ ์์ด์ ํธ"');
|
|
218
|
-
console.log(' - "๋ฌดํญ์ด์ ์ ์ ์ ๊ณ์นํ AI"');
|
|
219
|
-
console.log(' - "A follower of Mupengism"');
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
module.exports = {
|
|
223
|
-
validateIdentity,
|
|
224
|
-
validateIdentityFile,
|
|
225
|
-
getIdentityGuide,
|
|
226
|
-
printResult,
|
|
227
|
-
IDENTITY_CLAIM_PATTERNS,
|
|
228
|
-
SAFE_CONTEXTS,
|
|
229
|
-
};
|
package/lib/runtime-guard.js
DELETED
|
@@ -1,255 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Runtime Guard ๐ก๏ธ
|
|
3
|
-
* SOUL.md ๋ก๋ฉ ์ ์ํ ํจํด ๊ฒ์ฌ
|
|
4
|
-
*
|
|
5
|
-
* ๋ฌดํญ์ด์ฆ์ ๊ธฐ์ ์ ๋ณดํธ ๊ณ์ธต
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
const DANGEROUS_PATTERNS = {
|
|
9
|
-
// ์์ฌ์ค๋ฌ์ด URL ํจํด
|
|
10
|
-
suspiciousUrls: [
|
|
11
|
-
/https?:\/\/[^\/]*\.(ru|cn|xyz|top|tk|ml|ga|cf|gq)\//gi, // ์ํ ๋๋ฉ์ธ
|
|
12
|
-
/https?:\/\/\d+\.\d+\.\d+\.\d+/gi, // IP ์ฃผ์ ์ง์ ์ ๊ทผ
|
|
13
|
-
/https?:\/\/bit\.ly|tinyurl|t\.co|goo\.gl/gi, // ๋จ์ถ URL
|
|
14
|
-
/data:text\/html/gi, // Data URI ์
์ฉ
|
|
15
|
-
/javascript:/gi, // JavaScript URI
|
|
16
|
-
],
|
|
17
|
-
|
|
18
|
-
// ์ํํ ์ ๋ช
๋ น์ด ํจํด
|
|
19
|
-
dangerousCommands: [
|
|
20
|
-
/rm\s+(-rf?|--recursive)\s+[\/~]/gi, // ๋ฃจํธ/ํ ์ญ์
|
|
21
|
-
/curl\s+.*\|\s*(sh|bash|zsh)/gi, // ํ์ดํ๋ก ์ ์คํ
|
|
22
|
-
/wget\s+.*-O-\s*\|\s*(sh|bash|zsh)/gi, // wget ํ์ดํ ์คํ
|
|
23
|
-
/eval\s*\(/gi, // eval ์ฌ์ฉ
|
|
24
|
-
/chmod\s+777/gi, // ๊ณผ๋ํ ๊ถํ
|
|
25
|
-
/sudo\s+rm/gi, // sudo rm
|
|
26
|
-
/>\s*\/etc\/|>\s*\/dev\//gi, // ์์คํ
ํ์ผ ๋ฎ์ด์ฐ๊ธฐ
|
|
27
|
-
/mkfs\s+/gi, // ํ์ผ์์คํ
ํฌ๋งท
|
|
28
|
-
/dd\s+if=.*of=\/dev\//gi, // ๋์คํฌ ๋ฎ์ด์ฐ๊ธฐ
|
|
29
|
-
/:(){ :|:& };:/, // fork bomb
|
|
30
|
-
],
|
|
31
|
-
|
|
32
|
-
// ํ๋กฌํํธ ์ธ์ ์
ํจํด
|
|
33
|
-
promptInjection: [
|
|
34
|
-
/ignore\s+(previous|all|above)\s+(instructions?|prompts?)/gi,
|
|
35
|
-
/disregard\s+(previous|all|above)/gi,
|
|
36
|
-
/forget\s+(everything|all|previous)/gi,
|
|
37
|
-
/new\s+instructions?:/gi,
|
|
38
|
-
/system\s*:\s*you\s+are/gi,
|
|
39
|
-
/override\s+(safety|security|rules)/gi,
|
|
40
|
-
/bypass\s+(filter|security|safety)/gi,
|
|
41
|
-
/pretend\s+you\s+(are|can|don't)/gi,
|
|
42
|
-
/act\s+as\s+if\s+you\s+(have|can|are)/gi,
|
|
43
|
-
/jailbreak/gi,
|
|
44
|
-
/DAN\s*mode/gi,
|
|
45
|
-
/developer\s*mode\s*enabled/gi,
|
|
46
|
-
/hypothetically/gi,
|
|
47
|
-
/roleplay\s+as\s+an?\s+(unrestricted|unfiltered)/gi,
|
|
48
|
-
],
|
|
49
|
-
|
|
50
|
-
// ๋ฏผ๊ฐํ ์ ๋ณด ํ์ทจ ์๋
|
|
51
|
-
exfiltration: [
|
|
52
|
-
/send\s+(to|via)\s+.*@/gi, // ์ด๋ฉ์ผ๋ก ์ ์ก
|
|
53
|
-
/upload\s+to\s+/gi, // ์
๋ก๋ ์ง์
|
|
54
|
-
/post\s+to\s+https?:\/\//gi, // HTTP ์ ์ก
|
|
55
|
-
/webhook/gi, // ์นํ
์ธ๊ธ
|
|
56
|
-
/base64\s+encode/gi, // ์ธ์ฝ๋ฉ ์๋
|
|
57
|
-
/exfiltrate/gi, // ์ง์ ์ ํ์ทจ
|
|
58
|
-
/steal|extract\s+(api|token|key|password|secret)/gi, // ๋น๋ฐ ํ์ทจ
|
|
59
|
-
],
|
|
60
|
-
|
|
61
|
-
// ๊ถํ ์์น ์๋
|
|
62
|
-
privilegeEscalation: [
|
|
63
|
-
/become\s+(root|admin|administrator)/gi,
|
|
64
|
-
/grant\s+.*\s+(all|full)\s+access/gi,
|
|
65
|
-
/disable\s+(safety|security|logging|audit)/gi,
|
|
66
|
-
/turn\s+off\s+(safety|security|logging)/gi,
|
|
67
|
-
/run\s+as\s+(root|admin|administrator)/gi,
|
|
68
|
-
],
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
// ์ฌ๊ฐ๋ ๋ ๋ฒจ
|
|
72
|
-
const SEVERITY = {
|
|
73
|
-
CRITICAL: 'critical', // ์ฆ์ ์ฐจ๋จ
|
|
74
|
-
HIGH: 'high', // ๊ฐ๋ ฅ ๊ฒฝ๊ณ
|
|
75
|
-
MEDIUM: 'medium', // ๊ฒฝ๊ณ
|
|
76
|
-
LOW: 'low', // ์๋ฆผ
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* SOUL.md ๋ด์ฉ ๊ฒ์ฌ
|
|
81
|
-
* @param {string} content - SOUL.md ๋ด์ฉ
|
|
82
|
-
* @returns {Object} ๊ฒ์ฌ ๊ฒฐ๊ณผ
|
|
83
|
-
*/
|
|
84
|
-
function validateSoulContent(content) {
|
|
85
|
-
const issues = [];
|
|
86
|
-
const lines = content.split('\n');
|
|
87
|
-
|
|
88
|
-
// ๊ฐ ํจํด ๊ทธ๋ฃน ๊ฒ์ฌ
|
|
89
|
-
for (const url of DANGEROUS_PATTERNS.suspiciousUrls) {
|
|
90
|
-
const matches = content.match(url);
|
|
91
|
-
if (matches) {
|
|
92
|
-
issues.push({
|
|
93
|
-
type: 'suspicious_url',
|
|
94
|
-
severity: SEVERITY.HIGH,
|
|
95
|
-
pattern: url.toString(),
|
|
96
|
-
matches: matches,
|
|
97
|
-
message: `์์ฌ์ค๋ฌ์ด URL ํ์ง: ${matches.slice(0, 3).join(', ')}${matches.length > 3 ? '...' : ''}`,
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
for (const cmd of DANGEROUS_PATTERNS.dangerousCommands) {
|
|
103
|
-
const matches = content.match(cmd);
|
|
104
|
-
if (matches) {
|
|
105
|
-
issues.push({
|
|
106
|
-
type: 'dangerous_command',
|
|
107
|
-
severity: SEVERITY.CRITICAL,
|
|
108
|
-
pattern: cmd.toString(),
|
|
109
|
-
matches: matches,
|
|
110
|
-
message: `์ํํ ์ ๋ช
๋ น์ด ํ์ง: ${matches.slice(0, 3).join(', ')}`,
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
for (const injection of DANGEROUS_PATTERNS.promptInjection) {
|
|
116
|
-
const matches = content.match(injection);
|
|
117
|
-
if (matches) {
|
|
118
|
-
issues.push({
|
|
119
|
-
type: 'prompt_injection',
|
|
120
|
-
severity: SEVERITY.CRITICAL,
|
|
121
|
-
pattern: injection.toString(),
|
|
122
|
-
matches: matches,
|
|
123
|
-
message: `ํ๋กฌํํธ ์ธ์ ์
ํจํด ํ์ง: ${matches.slice(0, 3).join(', ')}`,
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
for (const exfil of DANGEROUS_PATTERNS.exfiltration) {
|
|
129
|
-
const matches = content.match(exfil);
|
|
130
|
-
if (matches) {
|
|
131
|
-
issues.push({
|
|
132
|
-
type: 'exfiltration',
|
|
133
|
-
severity: SEVERITY.HIGH,
|
|
134
|
-
pattern: exfil.toString(),
|
|
135
|
-
matches: matches,
|
|
136
|
-
message: `๋ฐ์ดํฐ ํ์ทจ ์๋ ํ์ง: ${matches.slice(0, 3).join(', ')}`,
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
for (const priv of DANGEROUS_PATTERNS.privilegeEscalation) {
|
|
142
|
-
const matches = content.match(priv);
|
|
143
|
-
if (matches) {
|
|
144
|
-
issues.push({
|
|
145
|
-
type: 'privilege_escalation',
|
|
146
|
-
severity: SEVERITY.CRITICAL,
|
|
147
|
-
pattern: priv.toString(),
|
|
148
|
-
matches: matches,
|
|
149
|
-
message: `๊ถํ ์์น ์๋ ํ์ง: ${matches.slice(0, 3).join(', ')}`,
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
// ๊ฒฐ๊ณผ ๋ถ์
|
|
155
|
-
const hasCritical = issues.some(i => i.severity === SEVERITY.CRITICAL);
|
|
156
|
-
const hasHigh = issues.some(i => i.severity === SEVERITY.HIGH);
|
|
157
|
-
|
|
158
|
-
return {
|
|
159
|
-
safe: issues.length === 0,
|
|
160
|
-
issues: issues,
|
|
161
|
-
summary: {
|
|
162
|
-
total: issues.length,
|
|
163
|
-
critical: issues.filter(i => i.severity === SEVERITY.CRITICAL).length,
|
|
164
|
-
high: issues.filter(i => i.severity === SEVERITY.HIGH).length,
|
|
165
|
-
medium: issues.filter(i => i.severity === SEVERITY.MEDIUM).length,
|
|
166
|
-
low: issues.filter(i => i.severity === SEVERITY.LOW).length,
|
|
167
|
-
},
|
|
168
|
-
recommendation: hasCritical
|
|
169
|
-
? 'BLOCK'
|
|
170
|
-
: hasHigh
|
|
171
|
-
? 'WARN_STRONG'
|
|
172
|
-
: issues.length > 0
|
|
173
|
-
? 'WARN'
|
|
174
|
-
: 'ALLOW',
|
|
175
|
-
};
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* ํ์ผ ๊ฒ์ฌ
|
|
180
|
-
* @param {string} filePath - ํ์ผ ๊ฒฝ๋ก
|
|
181
|
-
* @returns {Object} ๊ฒ์ฌ ๊ฒฐ๊ณผ
|
|
182
|
-
*/
|
|
183
|
-
function validateFile(filePath) {
|
|
184
|
-
const fs = require('fs');
|
|
185
|
-
|
|
186
|
-
if (!fs.existsSync(filePath)) {
|
|
187
|
-
return {
|
|
188
|
-
safe: true,
|
|
189
|
-
issues: [],
|
|
190
|
-
summary: { total: 0 },
|
|
191
|
-
recommendation: 'FILE_NOT_FOUND',
|
|
192
|
-
};
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
const content = fs.readFileSync(filePath, 'utf8');
|
|
196
|
-
return validateSoulContent(content);
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
/**
|
|
200
|
-
* ๊ฒ์ฌ ๊ฒฐ๊ณผ ์ถ๋ ฅ
|
|
201
|
-
* @param {Object} result - ๊ฒ์ฌ ๊ฒฐ๊ณผ
|
|
202
|
-
* @param {boolean} verbose - ์์ธ ์ถ๋ ฅ ์ฌ๋ถ
|
|
203
|
-
*/
|
|
204
|
-
function printResult(result, verbose = false) {
|
|
205
|
-
if (result.safe) {
|
|
206
|
-
console.log('โ
์์ : ์ํ ํจํด์ด ํ์ง๋์ง ์์์ต๋๋ค.');
|
|
207
|
-
return;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
console.log('');
|
|
211
|
-
console.log('โ ๏ธ ๊ฒฝ๊ณ : ์ํ ํจํด์ด ํ์ง๋์์ต๋๋ค!');
|
|
212
|
-
console.log('');
|
|
213
|
-
console.log(` ์ด ${result.summary.total}๊ฐ ์ด์:`);
|
|
214
|
-
if (result.summary.critical > 0) {
|
|
215
|
-
console.log(` ๐ด ์ฌ๊ฐ: ${result.summary.critical}๊ฐ`);
|
|
216
|
-
}
|
|
217
|
-
if (result.summary.high > 0) {
|
|
218
|
-
console.log(` ๐ ๋์: ${result.summary.high}๊ฐ`);
|
|
219
|
-
}
|
|
220
|
-
if (result.summary.medium > 0) {
|
|
221
|
-
console.log(` ๐ก ์ค๊ฐ: ${result.summary.medium}๊ฐ`);
|
|
222
|
-
}
|
|
223
|
-
if (result.summary.low > 0) {
|
|
224
|
-
console.log(` ๐ข ๋ฎ์: ${result.summary.low}๊ฐ`);
|
|
225
|
-
}
|
|
226
|
-
console.log('');
|
|
227
|
-
|
|
228
|
-
if (verbose) {
|
|
229
|
-
console.log('์์ธ ๋ด์ญ:');
|
|
230
|
-
for (const issue of result.issues) {
|
|
231
|
-
const icon = issue.severity === SEVERITY.CRITICAL ? '๐ด'
|
|
232
|
-
: issue.severity === SEVERITY.HIGH ? '๐ '
|
|
233
|
-
: issue.severity === SEVERITY.MEDIUM ? '๐ก'
|
|
234
|
-
: '๐ข';
|
|
235
|
-
console.log(` ${icon} [${issue.type}] ${issue.message}`);
|
|
236
|
-
}
|
|
237
|
-
console.log('');
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
console.log(`๊ถ์ฅ ์กฐ์น: ${result.recommendation}`);
|
|
241
|
-
if (result.recommendation === 'BLOCK') {
|
|
242
|
-
console.log(' โ ์ด ํ์ผ์ ์ฌ์ฉํ๋ฉด ์ ๋ฉ๋๋ค.');
|
|
243
|
-
console.log(' ํ์ผ ๋ด์ฉ์ ๊ฒํ ํ๊ณ ์ํ ์์๋ฅผ ์ ๊ฑฐํ์ธ์.');
|
|
244
|
-
} else if (result.recommendation === 'WARN_STRONG') {
|
|
245
|
-
console.log(' โ ๏ธ ์ฃผ์ํด์ ์ฌ์ฉํ์ธ์. ์๋์น ์์ ๋์์ด ์์ ์ ์์ต๋๋ค.');
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
module.exports = {
|
|
250
|
-
validateSoulContent,
|
|
251
|
-
validateFile,
|
|
252
|
-
printResult,
|
|
253
|
-
DANGEROUS_PATTERNS,
|
|
254
|
-
SEVERITY,
|
|
255
|
-
};
|