@offgridsec/kira-lite-mcp 0.1.2 → 0.1.3
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/PRIVACY.md +9 -1
- package/README.md +1 -1
- package/dist/config.d.ts +5 -0
- package/dist/config.js +1 -1
- package/dist/core/engines/kira-core.js +1 -1
- package/dist/core/engines/osv.js +485 -1
- package/dist/core/engines/runner.js +30 -1
- package/dist/core/scanner.js +101 -1
- package/dist/core/types.js +1 -1
- package/dist/core/utils.js +70 -1
- package/dist/index.js +477 -1
- package/dist/rules/c-cpp.js +202 -1
- package/dist/rules/cicd.js +144 -1
- package/dist/rules/csharp.js +207 -1
- package/dist/rules/docker.js +143 -1
- package/dist/rules/go.js +184 -1
- package/dist/rules/index.js +147 -1
- package/dist/rules/java.js +1 -1
- package/dist/rules/javascript-extended.js +1 -1
- package/dist/rules/javascript.js +1 -1
- package/dist/rules/kubernetes.js +1 -1
- package/dist/rules/php.js +1 -1
- package/dist/rules/python-extended.js +1 -1
- package/dist/rules/python.js +1 -1
- package/dist/rules/ruby.js +1 -1
- package/dist/rules/secrets-extended.js +1 -1
- package/dist/rules/secrets.js +1 -1
- package/dist/rules/shell.js +1 -1
- package/dist/rules/terraform.js +1 -1
- package/dist/telemetry.d.ts +1 -0
- package/dist/telemetry.js +1 -1
- package/dist/tools/fix-vulnerability.js +1 -1
- package/dist/tools/scan-code.js +1 -1
- package/dist/tools/scan-dependencies.js +1 -1
- package/dist/tools/scan-diff.js +1 -1
- package/dist/tools/scan-file.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1,30 @@
|
|
|
1
|
-
|
|
1
|
+
import { execFile } from "node:child_process";
|
|
2
|
+
import { promisify } from "node:util";
|
|
3
|
+
import { which } from "../utils.js";
|
|
4
|
+
const execFileAsync = promisify(execFile);
|
|
5
|
+
export async function runCommand(command, args, options) {
|
|
6
|
+
try {
|
|
7
|
+
const result = await execFileAsync(command, args, {
|
|
8
|
+
timeout: options?.timeout ?? 30_000,
|
|
9
|
+
cwd: options?.cwd,
|
|
10
|
+
maxBuffer: 10 * 1024 * 1024,
|
|
11
|
+
encoding: "utf-8",
|
|
12
|
+
...(options?.stdin ? { input: options.stdin } : {}),
|
|
13
|
+
});
|
|
14
|
+
return {
|
|
15
|
+
stdout: String(result.stdout),
|
|
16
|
+
stderr: String(result.stderr),
|
|
17
|
+
exitCode: 0,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
catch (err) {
|
|
21
|
+
return {
|
|
22
|
+
stdout: err.stdout ?? "",
|
|
23
|
+
stderr: err.stderr ?? err.message ?? String(err),
|
|
24
|
+
exitCode: err.code === "ETIMEDOUT" ? -1 : (err.status ?? 1),
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export async function isToolAvailable(name) {
|
|
29
|
+
return (await which(name)) !== null;
|
|
30
|
+
}
|
package/dist/core/scanner.js
CHANGED
|
@@ -1 +1,101 @@
|
|
|
1
|
-
function _0x2e6bad(_0x39958b,_0x12e043){const _0x3f7ae1={_0x3c6316:0x74};return _0x509f(_0x12e043- -_0x3f7ae1._0x3c6316,_0x39958b);}function _0x509f(_0x868c0,_0x4edc4b){_0x868c0=_0x868c0-(-0xe2e+-0x2*-0xc43+-0x95a);const _0x1f10b8=_0xd138();let _0x3fb244=_0x1f10b8[_0x868c0];if(_0x509f['hGvEPu']===undefined){var _0x5bb961=function(_0x2e8ba2){const _0x5bd3d9='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x468099='',_0x42b075='';for(let _0x8d00af=0x4*0x3cb+0xbdf+0x17*-0x12d,_0x27b006,_0x1512fd,_0x227967=0x17af+0x19bc+-0x316b;_0x1512fd=_0x2e8ba2['charAt'](_0x227967++);~_0x1512fd&&(_0x27b006=_0x8d00af%(0x3*-0x9b6+-0x1*0x38e+0x5b*0x5c)?_0x27b006*(-0x1*-0x709+-0x41c+-0x2ad)+_0x1512fd:_0x1512fd,_0x8d00af++%(-0xd*0x1e9+-0x2f*-0x5+0x17ee))?_0x468099+=String['fromCharCode'](0xe4b+-0x1*0x75+-0xcd7&_0x27b006>>(-(-0x1975+-0xbf3+-0x2*-0x12b5)*_0x8d00af&0x13f*-0x18+0x458+-0x28f*-0xa)):-0x16e1*-0x1+-0x1cb7+0x5d6){_0x1512fd=_0x5bd3d9['indexOf'](_0x1512fd);}for(let _0xce5a4=0x21d*-0x6+0x1614+-0x4b3*0x2,_0x380509=_0x468099['length'];_0xce5a4<_0x380509;_0xce5a4++){_0x42b075+='%'+('00'+_0x468099['charCodeAt'](_0xce5a4)['toString'](0x1bfc+0x1*0x15e5+-0x147*0x27))['slice'](-(0x29c*0x2+-0x1d5a+0x1824));}return decodeURIComponent(_0x42b075);};_0x509f['SijVPp']=_0x5bb961,_0x509f['KzOfCv']={},_0x509f['hGvEPu']=!![];}const _0x797192=_0x1f10b8[-0x268f*-0x1+0x6d*0x1+-0x26fc],_0x4b10c8=_0x868c0+_0x797192,_0x592748=_0x509f['KzOfCv'][_0x4b10c8];return!_0x592748?(_0x3fb244=_0x509f['SijVPp'](_0x3fb244),_0x509f['KzOfCv'][_0x4b10c8]=_0x3fb244):_0x3fb244=_0x592748,_0x3fb244;}(function(_0x50ce72,_0x1bb993){const _0x4cf69d={_0xd85d45:0x16d,_0x1cf49a:0x150,_0x68ab78:0x151,_0x24dabf:0x15c,_0x4c0c13:0x13f,_0x14c69b:0x173,_0x194243:0x17d,_0x4cf08e:0x36f,_0x1bea4b:0x375,_0x67cb18:0x15a,_0x1b95aa:0x372,_0xf19d36:0x373};function _0x357d6f(_0x5ed9ca,_0x37e17c){return _0x509f(_0x37e17c-0x239,_0x5ed9ca);}const _0xe6bbe3=_0x50ce72();function _0x438594(_0x2367df,_0x490f14){return _0x509f(_0x490f14- -0x281,_0x2367df);}while(!![]){try{const _0x409691=-parseInt(_0x438594(-_0x4cf69d._0xd85d45,-_0x4cf69d._0x1cf49a))/(0x1c2+-0x1fd*0x1+0x3c)+parseInt(_0x438594(-0x17a,-_0x4cf69d._0x68ab78))/(0x225d+0x30f*-0x9+0x5c*-0x13)+-parseInt(_0x357d6f(0x371,0x385))/(0x18f7+0x2a5*-0xe+0xc12)+parseInt(_0x438594(-_0x4cf69d._0x24dabf,-_0x4cf69d._0x4c0c13))/(0x42*-0x10+0x1*0x1819+-0x1*0x13f5)*(-parseInt(_0x438594(-_0x4cf69d._0x14c69b,-_0x4cf69d._0x194243))/(-0xc39+-0x167e+-0x2e5*-0xc))+-parseInt(_0x357d6f(_0x4cf69d._0x4cf08e,_0x4cf69d._0x1bea4b))/(0x16b6+-0x6b0+-0x2*0x800)+parseInt(_0x438594(-0x142,-0x158))/(-0x21e4+-0x18dc+0x3ac7)*(-parseInt(_0x438594(-0x151,-0x15c))/(-0x1c7f+0x20a2+0x1*-0x41b))+-parseInt(_0x438594(-_0x4cf69d._0x67cb18,-0x17a))/(-0x8*-0x3db+0x3bf*-0x1+-0x1b10)*(-parseInt(_0x357d6f(_0x4cf69d._0x1b95aa,_0x4cf69d._0xf19d36))/(0x11a2+-0x14e2+0x34a*0x1));if(_0x409691===_0x1bb993)break;else _0xe6bbe3['push'](_0xe6bbe3['shift']());}catch(_0x335460){_0xe6bbe3['push'](_0xe6bbe3['shift']());}}}(_0xd138,-0x6353c+-0x2cde+0xcbf13));function _0x5e8f43(_0x381a15,_0x5731a1){const _0x2ac8f8={_0x899ff6:0x35d};return _0x509f(_0x381a15- -_0x2ac8f8._0x899ff6,_0x5731a1);}import{detectLanguage,getRulesForLanguage}from'../rules/index.js';import{runKiraCore}from'./engines/kira-core.js';function _0xd138(){const _0x2fe60a=['C29YDa','tff4rwW','Axb0Aw8','BgvUz3q','ignYAxq','BwvKAxu','CYbVzIa','C2nHBLi','BgfUz3u','BMrLEa','C3bSAxq','v3rqANK','y3jPDgK','tgL0zsa','AwnHBa','igXVDW','C2v2zxi','qKnWCei','tg92sgO','quDcvwm','zML4','u3vTBwe','CMfIAwW','yw1L','AxrPzxm','ChvZAa','zwrmAw4','zMLUzgK','mtzWs2LozKG','qvvVz1O','y29Kzq','DgLLCYa','nti0mdKWsLP6tMzv','C29Tzq','Axr5','zMLSzw4','C2nHBM4','zMLSDgu','y2fS','odm0ntqYCLncB01p','nta5ndG0CMvoswvr','BM93','DgL0Bgu','ihz1Bg4','Aw5KzxG','C3rHDhu','DwXUzxi','ig1LzgK','BMDZ','mtbRAuPeu2G','y2XLyw4','ntqZmdbTsvDUwKq','x2zVDw4','whneEMy','CMvNzxG','ywjSzq','CMvZDwW','nhzyyvbOuG','iezVDw4','u0DMtgS','Cgf0Dgu','AM9PBG','DKjjEvi','zgv0zwm','BgfZDeK','s2LYys0','wKDtruu','mtKWotq3ouHzsg5bsq','DhjPBq','ywDL','vgnHuwi','DNvSBMu','Bg93','yxzHAwW','yNvPBgq','zgvZy3i','nta5otuWB2Heu2zu','Aw5MBW','C3vTBwe','mti2ntG1mJD6uLDtDxG','BgLUzq'];_0xd138=function(){return _0x2fe60a;};return _0xd138();}export class KiraScanner{[_0x5e8f43(-0x24d,-0x230)+'egex'](_0x4ecab5){const _0x34259d={_0x5ab143:0x295,_0x51ae1c:0x251,_0x39b0e5:0x280,_0x864bca:0x26e,_0x1697ce:0x29b,_0xce264c:0x2aa,_0x3910ea:0x2b0,_0x34ef05:0x287,_0x242bc0:0x1ab,_0x7fa773:0x1e8,_0x5e750d:0x1f3,_0x3b98b4:0x291,_0x2d17b0:0x1c9,_0x468188:0x1ed,_0x12c576:0x290,_0x101ee2:0x26f,_0x39da56:0x1c5,_0x40bd46:0x1d7,_0x437b1c:0x1ea,_0x4e52e8:0x24d,_0x2dd8ea:0x27d,_0x482f96:0x2b6,_0xbdd8ab:0x18b},_0x27f437={};_0x27f437[_0x3761b2(-_0x34259d._0x5ab143,-0x274)]=function(_0x19c5f1,_0x29b22e){return _0x19c5f1+_0x29b22e;},_0x27f437[_0x3761b2(-0x273,-0x29c)]=_0x670435(0x1de,0x1c4);const _0xc3efe7=_0x27f437,_0xf14bdb=Date[_0x3761b2(-_0x34259d._0x51ae1c,-0x268)](),_0x1becfa=detectLanguage(_0x4ecab5[_0x3761b2(-_0x34259d._0x39b0e5,-_0x34259d._0x864bca)+_0x3761b2(-_0x34259d._0x1697ce,-0x27a)],_0x4ecab5[_0x3761b2(-_0x34259d._0xce264c,-0x289)+_0x670435(0x1ed,0x1c9)]),_0x2fdf2b=getRulesForLanguage(_0x1becfa),_0xbd8a54=_0x4ecab5['code'][_0x3761b2(-_0x34259d._0x3910ea,-_0x34259d._0x34ef05)]('\x0a'),_0xadb771=[];function _0x670435(_0x4c2ee6,_0x29e747){return _0x5e8f43(_0x4c2ee6-0x3fc,_0x29e747);}for(const _0xc544b9 of _0x2fdf2b){for(let _0x5aafd4=0x1e2a+-0x32b*0xb+0x4af;_0x5aafd4<_0xbd8a54[_0x670435(_0x34259d._0x242bc0,0x19c)+'h'];_0x5aafd4++){const _0x59758f=_0xbd8a54[_0x5aafd4];_0xc544b9['patte'+'rn'][_0x670435(_0x34259d._0x7fa773,_0x34259d._0x5e750d)+_0x3761b2(-_0x34259d._0x3b98b4,-0x288)]=0x20ed+0x818+0x1*-0x2905;const _0x41fd0b=_0xc544b9[_0x670435(0x1e4,0x203)+'rn']['exec'](_0x59758f);if(_0x41fd0b){const _0x4d3bc1=_0xadb771[_0x670435(_0x34259d._0x2d17b0,_0x34259d._0x468188)](_0x1c3c69=>_0x1c3c69['id']===_0xc544b9['id']&&_0x1c3c69[_0x670435(0x1a7,0x186)]===_0x5aafd4+(0x8f*0x2b+-0x14f9+-0x30b));if(_0x4d3bc1)continue;_0xadb771['push']({'id':_0xc544b9['id'],'severity':_0xc544b9['sever'+_0x3761b2(-_0x34259d._0x12c576,-_0x34259d._0x101ee2)],'cwe':_0xc544b9['cwe'],'title':_0xc544b9[_0x3761b2(-0x257,-0x267)],'description':_0xc544b9[_0x670435(0x1a2,0x1c1)+_0x670435(0x1aa,0x1b7)+'n'],'line':_0x5aafd4+(-0x26c4+-0xb04+0x9f5*0x5),'column':_0xc3efe7[_0x670435(_0x34259d._0x39da56,_0x34259d._0x40bd46)](_0x41fd0b[_0x670435(0x1d4,_0x34259d._0x437b1c)],0x2141*0x1+-0x4db+-0x1c65),'snippet':_0x59758f[_0x3761b2(-0x22f,-_0x34259d._0x4e52e8)](),'fix':_0xc544b9[_0x3761b2(-0x264,-_0x34259d._0x2dd8ea)],'engine':_0xc3efe7['TcaQb']});}}}function _0x3761b2(_0x510e8c,_0x542a4e){return _0x5e8f43(_0x542a4e- -0x3d,_0x510e8c);}return{'findings':_0xadb771,'status':{'engine':_0xc3efe7[_0x3761b2(-_0x34259d._0x482f96,-0x29c)],'available':!![],'findingsCount':_0xadb771[_0x670435(0x1ab,_0x34259d._0xbdd8ab)+'h'],'durationMs':Date['now']()-_0xf14bdb}};}async['scan'](_0x3b862a){const _0x2120ff={_0x5724c7:0x5d,_0x287140:0x42,_0x454641:0x20,_0x1bc996:0x3d2,_0x33d5b5:0x3b6,_0x4bec71:0x75,_0x4bf6cd:0x3d,_0x33c7b0:0xd,_0x46cb4d:0x21,_0x6b74d9:0x40b,_0x3da28f:0x3ff,_0x2aa827:0x3fe,_0x293745:0x4d,_0x3afddb:0x32,_0x221398:0x10,_0x271190:0x41,_0x58c058:0x37,_0x4091fd:0x72,_0x463dc8:0x4b,_0x3edcde:0x28,_0x53c08d:0x37,_0xd08888:0x55,_0x3c4f3e:0x3d8,_0x4565c3:0x3f9,_0x46fd68:0x3f9,_0x4b87d3:0x3c8,_0x429e6c:0x3aa,_0xb88261:0x31,_0x2ab379:0x49,_0x38284f:0x3e7,_0x1f8f72:0x40d,_0x58fdc7:0x60,_0x188ac0:0x3bd,_0x2d89da:0x3a7,_0x4ed663:0x6a,_0x3155d7:0x3dc,_0x1a907f:0x3f,_0x41d67a:0x3ee,_0x3a889b:0x52,_0x2fdb75:0x34,_0x45be54:0x54,_0x125510:0x2d,_0x4ec9ab:0x3e5,_0x463c36:0x3c3,_0x3972bd:0x3db,_0x11847c:0x3c4,_0x32e394:0x3a,_0x44a07a:0x3d3,_0x565e89:0x3b4},_0x44b58b={_0x3a7ff8:0x1ff},_0x5e8a62={_0x4ce7ea:0x3da,_0x4951a3:0x3ec,_0x3e7c5a:0x354,_0x185a05:0x32c,_0x59e67b:0x3ff,_0x5c7ea0:0x3ec,_0x479840:0x341,_0x5e699c:0x31b},_0x300d97={_0x355a41:0x41f},_0x42e835={_0x5374db:0x615},_0x25f3ca={};_0x25f3ca[_0xae3bf2(-_0x2120ff._0x5724c7,-_0x2120ff._0x287140)]=function(_0x208d25,_0x3905d8){return _0x208d25-_0x3905d8;},_0x25f3ca[_0xae3bf2(-0x2f,-_0x2120ff._0x454641)]=function(_0x30ab3c,_0xb61d9e){return _0x30ab3c!==_0xb61d9e;},_0x25f3ca[_0x3a8107(0x3cc,_0x2120ff._0x1bc996)]=function(_0x4127c0,_0xec740b){return _0x4127c0-_0xec740b;},_0x25f3ca[_0x3a8107(0x3c2,_0x2120ff._0x33d5b5)]=_0xae3bf2(-_0x2120ff._0x4bec71,-0x5f)+_0x3a8107(0x3d7,0x3be)+_0xae3bf2(-0x32,-_0x2120ff._0x4bf6cd)+_0xae3bf2(-_0x2120ff._0x33c7b0,-_0x2120ff._0x46cb4d)+'d',_0x25f3ca[_0x3a8107(0x403,_0x2120ff._0x6b74d9)]=_0x3a8107(0x3f3,_0x2120ff._0x3da28f);const _0x5add6a=_0x25f3ca,_0x4b8270=detectLanguage(_0x3b862a['filen'+_0x3a8107(0x3d8,_0x2120ff._0x2aa827)],_0x3b862a[_0xae3bf2(-0x2e,-_0x2120ff._0x293745)+_0xae3bf2(-_0x2120ff._0x3afddb,-_0x2120ff._0x221398)]),_0x52655c=_0x3b862a[_0xae3bf2(-_0x2120ff._0x271190,-_0x2120ff._0x58c058)][_0xae3bf2(-_0x2120ff._0x4091fd,-_0x2120ff._0x463dc8)]('\x0a'),_0x505f7d=await runKiraCore(_0x3b862a[_0xae3bf2(-_0x2120ff._0x3edcde,-_0x2120ff._0x53c08d)],_0x4b8270,_0x3b862a[_0xae3bf2(-_0x2120ff._0xd08888,-0x32)+_0x3a8107(_0x2120ff._0x3c4f3e,0x3fa)]);if(_0x505f7d?.[_0x3a8107(0x3b9,0x3c6)+_0x3a8107(0x3f8,_0x2120ff._0x4565c3)])return _0x505f7d[_0x3a8107(_0x2120ff._0x46fd68,0x414)+'t'];const _0x412564=this[_0x3a8107(_0x2120ff._0x4b87d3,_0x2120ff._0x429e6c)+'egex'](_0x3b862a),_0x5bdc7e={};_0x5bdc7e[_0xae3bf2(-_0x2120ff._0xb88261,-_0x2120ff._0x2ab379)+_0x3a8107(_0x2120ff._0x38284f,_0x2120ff._0x1f8f72)]=0x0,_0x5bdc7e['high']=0x1,_0x5bdc7e[_0x3a8107(0x3c6,0x3b7)+'m']=0x2;function _0x3a8107(_0x49e360,_0x400eae){return _0x5e8f43(_0x49e360-_0x42e835._0x5374db,_0x400eae);}_0x5bdc7e[_0xae3bf2(-_0x2120ff._0x58fdc7,-0x5e)]=0x3,_0x5bdc7e[_0x3a8107(_0x2120ff._0x188ac0,_0x2120ff._0x2d89da)]=0x4;const _0x4baaf5=_0x5bdc7e;_0x412564['findi'+'ngs'][_0xae3bf2(-0x31,-0x55)]((_0x5e2d7a,_0x36505a)=>{function _0x8d94ea(_0x544ad8,_0xa9be7b){return _0xae3bf2(_0xa9be7b,_0x544ad8-_0x300d97._0x355a41);}const _0x16292a=_0x5add6a['AGBUc'](_0x4baaf5[_0x5e2d7a[_0x8d94ea(_0x5e8a62._0x4ce7ea,0x3bd)+_0x8d94ea(_0x5e8a62._0x4951a3,0x3df)]],_0x4baaf5[_0x36505a[_0x55e7e6(_0x5e8a62._0x3e7c5a,_0x5e8a62._0x185a05)+_0x55e7e6(0x35d,0x33e)]]);function _0x55e7e6(_0x149f2a,_0x319da9){return _0x3a8107(_0x319da9- -0xa5,_0x149f2a);}return _0x5add6a[_0x8d94ea(_0x5e8a62._0x59e67b,_0x5e8a62._0x5c7ea0)](_0x16292a,-0x50*0x2a+0x43a*-0x2+0x1594*0x1)?_0x16292a:_0x5add6a[_0x8d94ea(0x3d5,0x3f3)](_0x5e2d7a['line'],_0x36505a[_0x55e7e6(_0x5e8a62._0x479840,_0x5e8a62._0x5e699c)]);});function _0xae3bf2(_0x22ce68,_0x246430){return _0x5e8f43(_0x246430-_0x44b58b._0x3a7ff8,_0x22ce68);}const _0x2ac204=this[_0xae3bf2(-_0x2120ff._0x4ed663,-0x5c)+'Summa'+'ry'](_0x412564[_0x3a8107(_0x2120ff._0x3155d7,0x3b9)+_0xae3bf2(-_0x2120ff._0x1a907f,-0x25)],_0x4b8270,_0x52655c[_0xae3bf2(-0x31,-0x52)+'h']),_0xfea8b1={};return _0xfea8b1[_0x3a8107(_0x2120ff._0x41d67a,0x3f8)+'s']=_0x412564['findi'+_0xae3bf2(-0x4d,-0x25)][_0xae3bf2(-0x49,-_0x2120ff._0x3a889b)+'h']>-0x8b*0x5+-0x7a9*0x3+0x2e*0x8f?_0x5add6a[_0xae3bf2(-_0x2120ff._0x2fdb75,-_0x2120ff._0x45be54)]:_0x5add6a['ZGSEE'],_0xfea8b1[_0xae3bf2(-_0x2120ff._0x125510,-0x4d)+_0x3a8107(0x406,0x3eb)]=_0x4b8270,_0xfea8b1[_0x3a8107(_0x2120ff._0x4ec9ab,_0x2120ff._0x463c36)+_0x3a8107(_0x2120ff._0x3972bd,_0x2120ff._0x3972bd)+'es']=_0x52655c[_0x3a8107(_0x2120ff._0x11847c,0x39e)+'h'],_0xfea8b1[_0xae3bf2(-0x54,-_0x2120ff._0x32e394)+_0x3a8107(0x3f1,_0x2120ff._0x44a07a)]=_0x412564[_0x3a8107(0x3dc,_0x2120ff._0x565e89)+'ngs'],_0xfea8b1[_0x3a8107(0x3be,0x3bf)+'ry']=_0x2ac204,_0xfea8b1['engin'+'es']=[_0x412564['statu'+'s']],_0xfea8b1;}['build'+_0x2e6bad(0xbd,0xaa)+'ry'](_0x396c17,_0xc3bb57,_0x5607aa){const _0x6305d4={_0x2163a3:0x140,_0x4849e3:0x147,_0x21cf7:0x137,_0x350bc6:0x4dc,_0x391f74:0x4e3,_0x24b3c9:0x4fc,_0x241efb:0x4f8,_0x33fc7c:0x4fb,_0x38fa05:0x4fe,_0x56eb3f:0x114,_0x546c8a:0x152,_0x138ac9:0x12d,_0x274dc5:0x4a4,_0x490504:0xfc,_0x591419:0x11a,_0x3403b6:0x4e0,_0x1058c1:0x4c0,_0x440295:0x14c,_0x2da6a8:0x12e,_0x570bb5:0x12c,_0x46f3d4:0x123,_0x2efb51:0x4ae,_0x3e0cf7:0x4e2,_0xc5641c:0x4cf,_0x1f015c:0x4d8,_0xc2840f:0x4d6,_0xaa65cc:0x117,_0x272218:0x503,_0xcc553b:0x4d5,_0xc91943:0x4d6,_0x1e37ad:0x11e,_0x4df24d:0x137,_0x43b454:0x10d,_0x26fa6c:0x146},_0x4fb5b9={_0x1840c2:0x74},_0x17f310={};_0x17f310['BCppB']=function(_0x3525fa,_0x44f2f0){return _0x3525fa===_0x44f2f0;},_0x17f310[_0x108178(_0x6305d4._0x2163a3,_0x6305d4._0x4849e3)]='\x20No\x20v'+_0x108178(0x12a,_0x6305d4._0x21cf7)+'abili'+_0x13e8db(0x4f0,_0x6305d4._0x350bc6)+_0x13e8db(_0x6305d4._0x391f74,_0x6305d4._0x24b3c9)+'ted.',_0x17f310[_0x108178(0x115,0x11b)]=function(_0x229c7b,_0xd0812a){return _0x229c7b>_0xd0812a;},_0x17f310[_0x13e8db(0x4d1,_0x6305d4._0x241efb)]=function(_0x26aabe,_0x4a6cf0){return _0x26aabe>_0x4a6cf0;};const _0x42e00c=_0x17f310;let _0x3248c2=_0x13e8db(_0x6305d4._0x33fc7c,_0x6305d4._0x38fa05)+_0x108178(_0x6305d4._0x56eb3f,0x116)+_0x108178(_0x6305d4._0x546c8a,_0x6305d4._0x138ac9)+'ed\x20'+_0x5607aa+('\x20line'+_0x13e8db(_0x6305d4._0x274dc5,0x4c3))+_0xc3bb57+'.';if(_0x42e00c[_0x108178(_0x6305d4._0x490504,_0x6305d4._0x591419)](_0x396c17[_0x13e8db(_0x6305d4._0x3403b6,_0x6305d4._0x1058c1)+'h'],-0x1a61*0x1+0x19*-0x16c+-0x1*-0x3ded))return _0x3248c2+=_0x42e00c[_0x108178(0x129,_0x6305d4._0x4849e3)],_0x3248c2;const _0x6e4f00=_0x396c17[_0x108178(_0x6305d4._0x440295,_0x6305d4._0x2da6a8)+'r'](_0x29a5be=>_0x29a5be[_0x13e8db(0x4b4,0x4cd)+_0x108178(0x112,0x12b)]===_0x13e8db(0x4ae,0x4c9)+_0x108178(0x117,0x12f))[_0x108178(_0x6305d4._0x570bb5,0x10c)+'h'],_0x2c880f=_0x396c17[_0x108178(0x14e,0x12e)+'r'](_0x246d85=>_0x246d85['sever'+_0x13e8db(0x4ed,0x4df)]==='high')[_0x108178(_0x6305d4._0x46f3d4,0x10c)+'h'];function _0x108178(_0x716e99,_0x199f8c){return _0x2e6bad(_0x716e99,_0x199f8c-_0x4fb5b9._0x1840c2);}const _0x36d037=_0x396c17['filte'+'r'](_0x343624=>_0x343624[_0x108178(0xf3,0x119)+'ity']===_0x108178(0x116,0x10e)+'m')[_0x13e8db(_0x6305d4._0x2efb51,0x4c0)+'h'],_0x28d995=_0x396c17[_0x13e8db(0x4f7,_0x6305d4._0x3e0cf7)+'r'](_0x35a0d0=>_0x35a0d0['sever'+_0x108178(0x106,0x12b)]===_0x108178(0x117,0x100))[_0x13e8db(0x49a,0x4c0)+'h'],_0x4f8b9c=[];if(_0x42e00c[_0x13e8db(0x4ba,_0x6305d4._0xc5641c)](_0x6e4f00,0x1ecd+-0x1067+0x733*-0x2))_0x4f8b9c[_0x13e8db(_0x6305d4._0x1f015c,_0x6305d4._0xc2840f)](_0x6e4f00+(_0x108178(0xfc,0x10d)+_0x108178(0x12e,_0x6305d4._0xaa65cc)));if(_0x42e00c[_0x13e8db(_0x6305d4._0x272218,_0x6305d4._0x241efb)](_0x2c880f,0x1c05+-0xbcb*-0x3+-0x3f66))_0x4f8b9c[_0x13e8db(_0x6305d4._0xcc553b,_0x6305d4._0xc91943)](_0x2c880f+'\x20high');if(_0x36d037>-0xae9+0x25fd*0x1+-0x1b14)_0x4f8b9c[_0x13e8db(0x4c8,0x4d6)](_0x36d037+(_0x108178(_0x6305d4._0x1e37ad,0x138)+'um'));if(_0x42e00c['LovHj'](_0x28d995,-0x225f+0x272*0x8+0xecf))_0x4f8b9c[_0x108178(0x134,0x122)](_0x28d995+_0x108178(0x134,0x118));_0x3248c2+=_0x108178(_0x6305d4._0x4df24d,0x143)+'d\x20'+_0x396c17['lengt'+'h']+(_0x108178(_0x6305d4._0x43b454,0x134)+'erabi'+'litie'+'s:\x20')+_0x4f8b9c[_0x108178(0x142,_0x6305d4._0x26fa6c)](',\x20')+'.';function _0x13e8db(_0x13aa0a,_0x1a4ba4){return _0x2e6bad(_0x13aa0a,_0x1a4ba4-0x428);}return _0x3248c2;}}
|
|
1
|
+
import { detectLanguage, getRulesForLanguage } from "../rules/index.js";
|
|
2
|
+
import { runKiraCore } from "./engines/kira-core.js";
|
|
3
|
+
export class KiraScanner {
|
|
4
|
+
/**
|
|
5
|
+
* Synchronous regex-only scan (fast fallback, always available).
|
|
6
|
+
*/
|
|
7
|
+
scanRegex(options) {
|
|
8
|
+
const start = Date.now();
|
|
9
|
+
const language = detectLanguage(options.filename, options.language);
|
|
10
|
+
const rules = getRulesForLanguage(language);
|
|
11
|
+
const lines = options.code.split("\n");
|
|
12
|
+
const findings = [];
|
|
13
|
+
for (const rule of rules) {
|
|
14
|
+
for (let i = 0; i < lines.length; i++) {
|
|
15
|
+
const line = lines[i];
|
|
16
|
+
rule.pattern.lastIndex = 0;
|
|
17
|
+
const match = rule.pattern.exec(line);
|
|
18
|
+
if (match) {
|
|
19
|
+
const isDuplicate = findings.some((f) => f.id === rule.id && f.line === i + 1);
|
|
20
|
+
if (isDuplicate)
|
|
21
|
+
continue;
|
|
22
|
+
findings.push({
|
|
23
|
+
id: rule.id,
|
|
24
|
+
severity: rule.severity,
|
|
25
|
+
cwe: rule.cwe,
|
|
26
|
+
title: rule.title,
|
|
27
|
+
description: rule.description,
|
|
28
|
+
line: i + 1,
|
|
29
|
+
column: match.index + 1,
|
|
30
|
+
snippet: line.trim(),
|
|
31
|
+
fix: rule.fix,
|
|
32
|
+
engine: "regex",
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
findings,
|
|
39
|
+
status: {
|
|
40
|
+
engine: "regex",
|
|
41
|
+
available: true,
|
|
42
|
+
findingsCount: findings.length,
|
|
43
|
+
durationMs: Date.now() - start,
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Full async scan.
|
|
49
|
+
*
|
|
50
|
+
* Strategy:
|
|
51
|
+
* 1. If kira-core Go binary is available → use it (single binary, has everything)
|
|
52
|
+
* 2. Otherwise → fall back to regex engine
|
|
53
|
+
*/
|
|
54
|
+
async scan(options) {
|
|
55
|
+
const language = detectLanguage(options.filename, options.language);
|
|
56
|
+
const lines = options.code.split("\n");
|
|
57
|
+
// Strategy 1: Try kira-core binary (single Go binary with everything compiled in)
|
|
58
|
+
const kiraCoreResult = await runKiraCore(options.code, language, options.filename);
|
|
59
|
+
if (kiraCoreResult?.available) {
|
|
60
|
+
return kiraCoreResult.result;
|
|
61
|
+
}
|
|
62
|
+
// Strategy 2: Fall back to regex engine
|
|
63
|
+
const regexResult = this.scanRegex(options);
|
|
64
|
+
const severityOrder = { critical: 0, high: 1, medium: 2, low: 3, info: 4 };
|
|
65
|
+
regexResult.findings.sort((a, b) => {
|
|
66
|
+
const sevDiff = severityOrder[a.severity] - severityOrder[b.severity];
|
|
67
|
+
return sevDiff !== 0 ? sevDiff : a.line - b.line;
|
|
68
|
+
});
|
|
69
|
+
const summary = this.buildSummary(regexResult.findings, language, lines.length);
|
|
70
|
+
return {
|
|
71
|
+
status: regexResult.findings.length > 0 ? "vulnerabilities_found" : "clean",
|
|
72
|
+
language,
|
|
73
|
+
scannedLines: lines.length,
|
|
74
|
+
findings: regexResult.findings,
|
|
75
|
+
summary,
|
|
76
|
+
engines: [regexResult.status],
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
buildSummary(findings, language, totalLines) {
|
|
80
|
+
let summary = `Kira-Lite scanned ${totalLines} lines of ${language}.`;
|
|
81
|
+
if (findings.length === 0) {
|
|
82
|
+
summary += " No vulnerabilities detected.";
|
|
83
|
+
return summary;
|
|
84
|
+
}
|
|
85
|
+
const critical = findings.filter((f) => f.severity === "critical").length;
|
|
86
|
+
const high = findings.filter((f) => f.severity === "high").length;
|
|
87
|
+
const medium = findings.filter((f) => f.severity === "medium").length;
|
|
88
|
+
const low = findings.filter((f) => f.severity === "low").length;
|
|
89
|
+
const parts = [];
|
|
90
|
+
if (critical > 0)
|
|
91
|
+
parts.push(`${critical} critical`);
|
|
92
|
+
if (high > 0)
|
|
93
|
+
parts.push(`${high} high`);
|
|
94
|
+
if (medium > 0)
|
|
95
|
+
parts.push(`${medium} medium`);
|
|
96
|
+
if (low > 0)
|
|
97
|
+
parts.push(`${low} low`);
|
|
98
|
+
summary += ` Found ${findings.length} vulnerabilities: ${parts.join(", ")}.`;
|
|
99
|
+
return summary;
|
|
100
|
+
}
|
|
101
|
+
}
|
package/dist/core/types.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{};
|
|
1
|
+
export {};
|
package/dist/core/utils.js
CHANGED
|
@@ -1 +1,70 @@
|
|
|
1
|
-
|
|
1
|
+
import { execFile } from "node:child_process";
|
|
2
|
+
import { promisify } from "node:util";
|
|
3
|
+
import { mkdtemp, writeFile, rm } from "node:fs/promises";
|
|
4
|
+
import { tmpdir } from "node:os";
|
|
5
|
+
import { join } from "node:path";
|
|
6
|
+
const execFileAsync = promisify(execFile);
|
|
7
|
+
const extensionMap = {
|
|
8
|
+
javascript: ".js",
|
|
9
|
+
typescript: ".ts",
|
|
10
|
+
python: ".py",
|
|
11
|
+
java: ".java",
|
|
12
|
+
go: ".go",
|
|
13
|
+
ruby: ".rb",
|
|
14
|
+
php: ".php",
|
|
15
|
+
csharp: ".cs",
|
|
16
|
+
c: ".c",
|
|
17
|
+
cpp: ".cpp",
|
|
18
|
+
rust: ".rs",
|
|
19
|
+
swift: ".swift",
|
|
20
|
+
kotlin: ".kt",
|
|
21
|
+
scala: ".scala",
|
|
22
|
+
shell: ".sh",
|
|
23
|
+
bash: ".sh",
|
|
24
|
+
yaml: ".yaml",
|
|
25
|
+
json: ".json",
|
|
26
|
+
xml: ".xml",
|
|
27
|
+
html: ".html",
|
|
28
|
+
css: ".css",
|
|
29
|
+
sql: ".sql",
|
|
30
|
+
dockerfile: "Dockerfile",
|
|
31
|
+
terraform: ".tf",
|
|
32
|
+
hcl: ".tf",
|
|
33
|
+
};
|
|
34
|
+
export function getExtensionForLanguage(language) {
|
|
35
|
+
if (!language)
|
|
36
|
+
return ".js";
|
|
37
|
+
return extensionMap[language.toLowerCase()] ?? ".txt";
|
|
38
|
+
}
|
|
39
|
+
export async function writeTempFile(code, language, filename) {
|
|
40
|
+
const dir = await mkdtemp(join(tmpdir(), "kira-"));
|
|
41
|
+
const ext = filename
|
|
42
|
+
? filename.slice(filename.lastIndexOf("."))
|
|
43
|
+
: getExtensionForLanguage(language);
|
|
44
|
+
const name = filename ? filename.replace(/[/\\]/g, "_") : `scan${ext}`;
|
|
45
|
+
const filePath = join(dir, name);
|
|
46
|
+
await writeFile(filePath, code, "utf-8");
|
|
47
|
+
return {
|
|
48
|
+
dir,
|
|
49
|
+
filePath,
|
|
50
|
+
cleanup: async () => {
|
|
51
|
+
try {
|
|
52
|
+
await rm(dir, { recursive: true, force: true });
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
// best effort
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
export async function which(command) {
|
|
61
|
+
try {
|
|
62
|
+
const cmd = process.platform === "win32" ? "where" : "which";
|
|
63
|
+
const { stdout } = await execFileAsync(cmd, [command], { timeout: 5000 });
|
|
64
|
+
const path = stdout.trim().split("\n")[0];
|
|
65
|
+
return path || null;
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
}
|