@shriyanss/js-recon 1.1.3-alpha.1 → 1.1.3-beta.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/.github/workflows/build-and-prettify.yaml +22 -23
- package/.prettierrc +2 -1
- package/CHANGELOG.md +26 -0
- package/build/api_gateway/checkFeasibility.js.map +1 -1
- package/build/api_gateway/checkFireWallBlocking.js.map +1 -1
- package/build/api_gateway/genReq.js.map +1 -1
- package/build/api_gateway/index.js +2 -3
- package/build/api_gateway/index.js.map +1 -1
- package/build/endpoints/gen_report/utility/iterate_n_store.js.map +1 -1
- package/build/endpoints/index.js.map +1 -1
- package/build/endpoints/next_js/client_jsFilesHref.js +4 -8
- package/build/endpoints/next_js/client_jsFilesHref.js.map +1 -1
- package/build/endpoints/next_js/client_jsonParse.js.map +1 -1
- package/build/endpoints/next_js/client_subsequentRequests.js +3 -7
- package/build/endpoints/next_js/client_subsequentRequests.js.map +1 -1
- package/build/endpoints/next_js/getWebpacks.js.map +1 -1
- package/build/globalConfig.js +3 -1
- package/build/globalConfig.js.map +1 -1
- package/build/index.js.map +1 -1
- package/build/lazyLoad/downloadFilesUtil.js.map +1 -1
- package/build/lazyLoad/downloadLoadedJsUtil.js +1 -2
- package/build/lazyLoad/downloadLoadedJsUtil.js.map +1 -1
- package/build/lazyLoad/index.js +2 -3
- package/build/lazyLoad/index.js.map +1 -1
- package/build/lazyLoad/next_js/next_GetJSScript.js +1 -2
- package/build/lazyLoad/next_js/next_GetJSScript.js.map +1 -1
- package/build/lazyLoad/next_js/next_GetLazyResourcesBuildManifestJs.js +1 -2
- package/build/lazyLoad/next_js/next_GetLazyResourcesBuildManifestJs.js.map +1 -1
- package/build/lazyLoad/next_js/next_GetLazyResourcesWebpackJs.js +3 -5
- package/build/lazyLoad/next_js/next_GetLazyResourcesWebpackJs.js.map +1 -1
- package/build/lazyLoad/next_js/next_SubsequentRequests.js +2 -6
- package/build/lazyLoad/next_js/next_SubsequentRequests.js.map +1 -1
- package/build/lazyLoad/nuxt_js/nuxt_astParse.js.map +1 -1
- package/build/lazyLoad/nuxt_js/nuxt_getFromPageSource.js +1 -2
- package/build/lazyLoad/nuxt_js/nuxt_getFromPageSource.js.map +1 -1
- package/build/lazyLoad/nuxt_js/nuxt_stringAnalysisJSFiles.js.map +1 -1
- package/build/lazyLoad/svelte/svelte_getFromPageSource.js.map +1 -1
- package/build/lazyLoad/svelte/svelte_stringAnalysisJSFiles.js.map +1 -1
- package/build/map/index.js +1 -1
- package/build/map/index.js.map +1 -1
- package/build/map/next_js/getAxiosInstances.js.map +1 -1
- package/build/map/next_js/getFetchInstances.js +3 -7
- package/build/map/next_js/getFetchInstances.js.map +1 -1
- package/build/map/next_js/getWebpackConnections.js +4 -11
- package/build/map/next_js/getWebpackConnections.js.map +1 -1
- package/build/map/next_js/interactive_helpers/commandHandler.js +3 -7
- package/build/map/next_js/interactive_helpers/commandHandler.js.map +1 -1
- package/build/map/next_js/interactive_helpers/commandHelpers.js.map +1 -1
- package/build/map/next_js/interactive_helpers/keybindings.js.map +1 -1
- package/build/map/next_js/resolveAxios.js +51 -218
- package/build/map/next_js/resolveAxios.js.map +1 -1
- package/build/map/next_js/resolveAxiosHelpers/astNodeToJsonString.js +52 -0
- package/build/map/next_js/resolveAxiosHelpers/astNodeToJsonString.js.map +1 -0
- package/build/map/next_js/resolveAxiosHelpers/findAxiosClients.js +26 -0
- package/build/map/next_js/resolveAxiosHelpers/findAxiosClients.js.map +1 -0
- package/build/map/next_js/resolveAxiosHelpers/findAxiosInstance.js +31 -0
- package/build/map/next_js/resolveAxiosHelpers/findAxiosInstance.js.map +1 -0
- package/build/map/next_js/resolveAxiosHelpers/handleAxiosCreate.js +101 -0
- package/build/map/next_js/resolveAxiosHelpers/handleAxiosCreate.js.map +1 -0
- package/build/map/next_js/resolveAxiosHelpers/processAxiosCall.js +103 -0
- package/build/map/next_js/resolveAxiosHelpers/processAxiosCall.js.map +1 -0
- package/build/map/next_js/resolveFetch.js +9 -9
- package/build/map/next_js/resolveFetch.js.map +1 -1
- package/build/map/next_js/utils.js +131 -24
- package/build/map/next_js/utils.js.map +1 -1
- package/build/run/index.js.map +1 -1
- package/build/strings/index.js +3 -7
- package/build/strings/index.js.map +1 -1
- package/build/strings/openapi.js.map +1 -1
- package/build/strings/permutate.js.map +1 -1
- package/build/strings/secrets.js.map +1 -1
- package/build/techDetect/index.js +8 -20
- package/build/techDetect/index.js.map +1 -1
- package/build/utility/ai.js.map +1 -1
- package/build/utility/makeReq.js +3 -3
- package/build/utility/makeReq.js.map +1 -1
- package/build/utility/openapiGenerator.js +55 -8
- package/build/utility/openapiGenerator.js.map +1 -1
- package/build/utility/resolvePath.js.map +1 -1
- package/package.json +1 -1
|
@@ -8,238 +8,71 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import chalk from "chalk";
|
|
11
|
-
import { resolveNodeValue, resolveStringOps } from "./utils.js";
|
|
12
|
-
import fs from "fs";
|
|
13
11
|
import parser from "@babel/parser";
|
|
14
12
|
import _traverse from "@babel/traverse";
|
|
15
|
-
import
|
|
13
|
+
import { findAxiosClients } from "./resolveAxiosHelpers/findAxiosClients.js";
|
|
14
|
+
import { findAxiosInstance } from "./resolveAxiosHelpers/findAxiosInstance.js";
|
|
15
|
+
import { processAxiosCall } from "./resolveAxiosHelpers/processAxiosCall.js";
|
|
16
16
|
const traverse = _traverse.default;
|
|
17
|
+
const getThirdArg = (ast) => {
|
|
18
|
+
let thirdArg = "";
|
|
19
|
+
traverse(ast, {
|
|
20
|
+
enter(path) {
|
|
21
|
+
let funcNode = null;
|
|
22
|
+
if (path.isFunctionDeclaration()) {
|
|
23
|
+
funcNode = path.node;
|
|
24
|
+
}
|
|
25
|
+
else if (path.isAssignmentExpression() && path.node.right.type === "ArrowFunctionExpression") {
|
|
26
|
+
funcNode = path.node.right;
|
|
27
|
+
}
|
|
28
|
+
if (funcNode && funcNode.params.length === 3) {
|
|
29
|
+
const thirdParam = funcNode.params[2];
|
|
30
|
+
if (thirdParam.type === "Identifier") {
|
|
31
|
+
thirdArg = thirdParam.name;
|
|
32
|
+
path.stop();
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
return thirdArg;
|
|
38
|
+
};
|
|
17
39
|
const resolveAxios = (chunks, directory) => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
40
|
console.log(chalk.cyan("[i] Resolving axios instances"));
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
for (const chunkName of Object.keys(chunks)) {
|
|
24
|
-
if (chunks[chunkName].isAxiosClient) {
|
|
25
|
-
axiosInstancesExists = true;
|
|
26
|
-
axiosExportedTo.push(chunkName);
|
|
27
|
-
}
|
|
41
|
+
const { axiosExportedTo, axiosImportedTo } = findAxiosClients(chunks);
|
|
42
|
+
if (axiosExportedTo.length === 0) {
|
|
43
|
+
console.log(chalk.yellow("[!] No axios clients defined in any chunk."));
|
|
44
|
+
return;
|
|
28
45
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
for (const axiosExportFunctionId of axiosExportedTo) {
|
|
33
|
-
// iterate through the imports of the all the chunks, and see which ones have axios clients imported
|
|
34
|
-
for (const importName of chunks[chunkName].imports) {
|
|
35
|
-
if (importName === axiosExportFunctionId) {
|
|
36
|
-
axiosImportedTo[chunkName] = axiosExportFunctionId;
|
|
37
|
-
console.log(chalk.green(`[✓] ${chunkName} imports axios client ${axiosExportFunctionId}`));
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
46
|
+
if (Object.keys(axiosImportedTo).length === 0) {
|
|
47
|
+
console.log(chalk.yellow("[!] No chunks import any of the defined axios clients."));
|
|
48
|
+
return;
|
|
41
49
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
let thirdArg = "";
|
|
55
|
-
traverse(ast, {
|
|
56
|
-
FunctionDeclaration(path) {
|
|
57
|
-
const args = path.node.params;
|
|
58
|
-
if (args.length === 3) {
|
|
59
|
-
thirdArg = args[2].name;
|
|
60
|
-
}
|
|
61
|
-
},
|
|
62
|
-
AssignmentExpression(path) {
|
|
63
|
-
const args = path.node.right.params;
|
|
64
|
-
if ((args === null || args === void 0 ? void 0 : args.length) === 3) {
|
|
65
|
-
thirdArg = args[2].name;
|
|
66
|
-
}
|
|
67
|
-
},
|
|
68
|
-
});
|
|
69
|
-
if (thirdArg !== "") {
|
|
70
|
-
let axiosInstance = "";
|
|
71
|
-
// get the var name for something like `a = thirdArg(<some_number>)`
|
|
50
|
+
for (const chunkName of Object.keys(axiosImportedTo)) {
|
|
51
|
+
const chunk = chunks[chunkName];
|
|
52
|
+
const chunkCode = chunk.code;
|
|
53
|
+
const ast = parser.parse(chunkCode, {
|
|
54
|
+
sourceType: "unambiguous",
|
|
55
|
+
plugins: ["jsx", "typescript"],
|
|
56
|
+
errorRecovery: true,
|
|
57
|
+
});
|
|
58
|
+
const thirdArg = getThirdArg(ast);
|
|
59
|
+
if (thirdArg) {
|
|
60
|
+
const axiosInstance = findAxiosInstance(ast, thirdArg, axiosImportedTo[chunkName], chunkName);
|
|
61
|
+
if (axiosInstance) {
|
|
72
62
|
traverse(ast, {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
const varName = path.node.id.name;
|
|
76
|
-
const assignmentValue = path.node.init;
|
|
77
|
-
if ((assignmentValue === null || assignmentValue === void 0 ? void 0 : assignmentValue.type) === "CallExpression") {
|
|
78
|
-
// see if it is calling the third arg
|
|
79
|
-
if (assignmentValue.callee.name === thirdArg) {
|
|
80
|
-
// finally, check if the first argument is equal to the axios instance
|
|
81
|
-
const thisFunctionAssignmentValue = assignmentValue.arguments[0].value.toString();
|
|
82
|
-
const targetFunctionAssignmentValue = axiosImportedTo[chunkName];
|
|
83
|
-
if (thisFunctionAssignmentValue ===
|
|
84
|
-
targetFunctionAssignmentValue) {
|
|
85
|
-
// print the variable name
|
|
86
|
-
console.log(chalk.green(`[✓] ${chunkName} uses axios client initialized in ${varName}`));
|
|
87
|
-
axiosInstance = varName;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
63
|
+
MemberExpression(path) {
|
|
64
|
+
processAxiosCall(path, axiosInstance, chunkCode, directory, chunkName, chunks, ast);
|
|
91
65
|
},
|
|
92
66
|
});
|
|
93
|
-
if (axiosInstance !== "") {
|
|
94
|
-
// now that we've got the axios instance, we need to find where it is being called
|
|
95
|
-
// for example, if the axios instance is `a`, then it is being called like `a.b.get(...)`
|
|
96
|
-
traverse(ast, {
|
|
97
|
-
MemberExpression(path) {
|
|
98
|
-
if (path.node.object.type === "MemberExpression" &&
|
|
99
|
-
path.node.object.object.name === axiosInstance) {
|
|
100
|
-
// This handles o.A.post
|
|
101
|
-
const codeSnippet = chunkCode.split("\n")[path.node.loc.start.line - 1];
|
|
102
|
-
const firstProp = path.node.object.property.name; // A
|
|
103
|
-
const secondProp = path.node.property.name; // post
|
|
104
|
-
let axiosFirstArg;
|
|
105
|
-
let axiosSecondArg;
|
|
106
|
-
let axiosFirstArgText;
|
|
107
|
-
let axiosSecondArgText;
|
|
108
|
-
// define some arguments to be finally printed
|
|
109
|
-
let callUrl;
|
|
110
|
-
let callMethod;
|
|
111
|
-
let callHeaders;
|
|
112
|
-
let callBody;
|
|
113
|
-
let functionFile;
|
|
114
|
-
let functionFileLine;
|
|
115
|
-
let chunkId;
|
|
116
|
-
// now, resolve the arguments
|
|
117
|
-
if (path.parentPath.isCallExpression()) {
|
|
118
|
-
const args = path.parentPath.node.arguments;
|
|
119
|
-
if (args.length > 0) {
|
|
120
|
-
axiosFirstArg = args[0];
|
|
121
|
-
axiosFirstArgText = chunkCode.slice(axiosFirstArg.start, axiosFirstArg.end);
|
|
122
|
-
// try to resolve this by seeing where this ends at
|
|
123
|
-
// the code snippet is `"/api/teams/".concat(i, "/members")`
|
|
124
|
-
// so, first of all see if this is a string operation
|
|
125
|
-
// regex for only concat ops
|
|
126
|
-
const concatRegex = /".*"(\.concat\(.+\))+/;
|
|
127
|
-
if (concatRegex.test(axiosFirstArgText)) {
|
|
128
|
-
// now, resolve it
|
|
129
|
-
// assuming that the code is like `"/api/teams/".concat(i, "/members")`
|
|
130
|
-
// Replace variables with placeholders using resolveStringOps utility
|
|
131
|
-
const varsReplaced = resolveStringOps(axiosFirstArgText);
|
|
132
|
-
callUrl = varsReplaced;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
if (args.length > 1) {
|
|
136
|
-
axiosSecondArg = args[1];
|
|
137
|
-
axiosSecondArgText = chunkCode.slice(axiosSecondArg.start, axiosSecondArg.end);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
// console.log(axiosFirstArgText, axiosSecondArgText);
|
|
141
|
-
// since it has got the two arguments, check their types
|
|
142
|
-
// first resolve the chunk id
|
|
143
|
-
chunkId = chunkName;
|
|
144
|
-
// now, get the function file
|
|
145
|
-
functionFile =
|
|
146
|
-
directory + "/" + chunks[chunkId].file;
|
|
147
|
-
// now, get the function file line
|
|
148
|
-
// to do so, iterate through the lines of code, and see if it is equal to codeSnippet
|
|
149
|
-
const codeFileContent = fs.readFileSync(functionFile, "utf-8");
|
|
150
|
-
for (let i = 0; i < codeFileContent.split("\n").length; i++) {
|
|
151
|
-
if (codeFileContent.split("\n")[i] ===
|
|
152
|
-
codeSnippet) {
|
|
153
|
-
functionFileLine = i + 1;
|
|
154
|
-
break;
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
// resolve the URL first in case it hasn't been resolved earlier
|
|
158
|
-
if (callUrl === undefined) {
|
|
159
|
-
if ((axiosFirstArg === null || axiosFirstArg === void 0 ? void 0 : axiosFirstArg.type) === "StringLiteral") {
|
|
160
|
-
callUrl = axiosFirstArg.value;
|
|
161
|
-
}
|
|
162
|
-
else {
|
|
163
|
-
// since it isn't a string, we have to resolve it
|
|
164
|
-
const callExpressionPath = path.parentPath;
|
|
165
|
-
// will also pass the code snippet just in case it could resolve it
|
|
166
|
-
callUrl = resolveNodeValue(axiosFirstArg, callExpressionPath.scope, axiosFirstArgText);
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
// now, go for the method
|
|
170
|
-
if (secondProp === "post" ||
|
|
171
|
-
secondProp === "POST") {
|
|
172
|
-
callMethod = "POST";
|
|
173
|
-
}
|
|
174
|
-
else if (secondProp === "get" ||
|
|
175
|
-
secondProp === "GET") {
|
|
176
|
-
callMethod = "GET";
|
|
177
|
-
}
|
|
178
|
-
else if (secondProp === "put" ||
|
|
179
|
-
secondProp === "PUT") {
|
|
180
|
-
callMethod = "PUT";
|
|
181
|
-
}
|
|
182
|
-
else if (secondProp === "delete" ||
|
|
183
|
-
secondProp === "DELETE") {
|
|
184
|
-
callMethod = "DELETE";
|
|
185
|
-
}
|
|
186
|
-
else if (secondProp === "patch" ||
|
|
187
|
-
secondProp === "PATCH") {
|
|
188
|
-
callMethod = "PATCH";
|
|
189
|
-
}
|
|
190
|
-
else if (secondProp === "head" ||
|
|
191
|
-
secondProp === "HEAD") {
|
|
192
|
-
callMethod = "HEAD";
|
|
193
|
-
}
|
|
194
|
-
else if (secondProp === "options" ||
|
|
195
|
-
secondProp === "OPTIONS") {
|
|
196
|
-
callMethod = "OPTIONS";
|
|
197
|
-
}
|
|
198
|
-
else if (secondProp === "trace" ||
|
|
199
|
-
secondProp === "TRACE") {
|
|
200
|
-
callMethod = "TRACE";
|
|
201
|
-
}
|
|
202
|
-
else if (secondProp === "connect" ||
|
|
203
|
-
secondProp === "CONNECT") {
|
|
204
|
-
callMethod = "CONNECT";
|
|
205
|
-
}
|
|
206
|
-
else {
|
|
207
|
-
callMethod = "UNKNOWN";
|
|
208
|
-
}
|
|
209
|
-
// finally, print the human readable output
|
|
210
|
-
console.log(chalk.blue(`[+] Found axios call in chunk ${chunkId} (${functionFile}) at L${functionFileLine}`));
|
|
211
|
-
console.log(chalk.green(` URL: ${callUrl}`));
|
|
212
|
-
console.log(chalk.green(` Method: ${callMethod}`));
|
|
213
|
-
globals.addOpenapiOutput({
|
|
214
|
-
url: callUrl || "",
|
|
215
|
-
method: callMethod || "",
|
|
216
|
-
path: callUrl || "",
|
|
217
|
-
headers: callHeaders || {},
|
|
218
|
-
body: callBody || "",
|
|
219
|
-
chunkId: chunkId,
|
|
220
|
-
functionFile: functionFile,
|
|
221
|
-
functionFileLine: functionFileLine,
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
|
-
},
|
|
225
|
-
});
|
|
226
|
-
}
|
|
227
|
-
else {
|
|
228
|
-
console.log(chalk.yellow("[!] No axios instance found in " + chunkName));
|
|
229
|
-
}
|
|
230
67
|
}
|
|
231
68
|
else {
|
|
232
|
-
console.log(chalk.yellow(
|
|
69
|
+
console.log(chalk.yellow(`[!] No axios instance found in ${chunkName}`));
|
|
233
70
|
}
|
|
234
71
|
}
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
}
|
|
240
|
-
if (!axiosInstancesExists) {
|
|
241
|
-
console.log(chalk.yellow("[!] No axios instances found"));
|
|
242
|
-
return;
|
|
72
|
+
else {
|
|
73
|
+
// This case might not be an error, just a different pattern.
|
|
74
|
+
// console.log(chalk.yellow(`[!] Could not find a function with 3 arguments in ${chunkName}`));
|
|
75
|
+
}
|
|
243
76
|
}
|
|
244
77
|
});
|
|
245
78
|
export default resolveAxios;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveAxios.js","sourceRoot":"","sources":["../../../src/map/next_js/resolveAxios.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"resolveAxios.js","sourceRoot":"","sources":["../../../src/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I,EAAE,aAAa,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;oBACxF,CAAC;iBACJ,CAAC,CAAC;YACP,CAAC;iBAAM,CAAC;gBACJ,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,kCAAkC,SAAS,EAAE,CAAC,CAAC,CAAC;YAC7E,CAAC;QACL,CAAC;aAAM,CAAC;YACJ,6DAA6D;YAC7D,+FAA+F;QACnG,CAAC;IACL,CAAC;AACL,CAAC,CAAA,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
export const astNodeToJsonString = (node, code) => {
|
|
2
|
+
if (!node) {
|
|
3
|
+
return '""';
|
|
4
|
+
}
|
|
5
|
+
switch (node.type) {
|
|
6
|
+
case "ObjectExpression": {
|
|
7
|
+
const props = node.properties
|
|
8
|
+
.map((prop) => {
|
|
9
|
+
if (prop.type === "ObjectProperty") {
|
|
10
|
+
const key = astNodeToJsonString(prop.key, code);
|
|
11
|
+
const value = astNodeToJsonString(prop.value, code);
|
|
12
|
+
return `${key}: ${value}`;
|
|
13
|
+
}
|
|
14
|
+
else if (prop.type === "SpreadElement") {
|
|
15
|
+
// Handle spread elements by trying to resolve them, or returning a placeholder
|
|
16
|
+
return `"...${astNodeToJsonString(prop.argument, code)}"`;
|
|
17
|
+
}
|
|
18
|
+
return null; // Or handle other property types if necessary
|
|
19
|
+
})
|
|
20
|
+
.filter(Boolean);
|
|
21
|
+
return `{${props.join(", ")}}`;
|
|
22
|
+
}
|
|
23
|
+
case "ArrayExpression": {
|
|
24
|
+
const elements = node.elements.map((elem) => astNodeToJsonString(elem, code));
|
|
25
|
+
return `[${elements.join(", ")}]`;
|
|
26
|
+
}
|
|
27
|
+
case "StringLiteral": {
|
|
28
|
+
return JSON.stringify(node.value);
|
|
29
|
+
}
|
|
30
|
+
case "NumericLiteral": {
|
|
31
|
+
return String(node.value);
|
|
32
|
+
}
|
|
33
|
+
case "BooleanLiteral": {
|
|
34
|
+
return String(node.value);
|
|
35
|
+
}
|
|
36
|
+
case "NullLiteral": {
|
|
37
|
+
return "null";
|
|
38
|
+
}
|
|
39
|
+
case "Identifier": {
|
|
40
|
+
return `"${node.name}"`;
|
|
41
|
+
}
|
|
42
|
+
case "MemberExpression": {
|
|
43
|
+
// Reconstruct the member expression as a string, removing newlines
|
|
44
|
+
return `"${code.slice(node.start, node.end).replace(/\n\s*/g, " ")}"`;
|
|
45
|
+
}
|
|
46
|
+
default: {
|
|
47
|
+
// For any other node types, slice the original code, remove newlines, and wrap in quotes
|
|
48
|
+
return `"${code.slice(node.start, node.end).replace(/\n\s*/g, " ")}"`;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=astNodeToJsonString.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"astNodeToJsonString.js","sourceRoot":"","sources":["../../../../src/map/next_js/resolveAxiosHelpers/astNodeToJsonString.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,IAAU,EAAE,IAAY,EAAU,EAAE;IACpE,IAAI,CAAC,IAAI,EAAE,CAAC;QACR,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,QAAQ,IAAI,CAAC,IAAI,EAAE,CAAC;QAChB,KAAK,kBAAkB,CAAC,CAAC,CAAC;YACtB,MAAM,KAAK,GAAG,IAAI,CAAC,UAAU;iBACxB,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;gBACV,IAAI,IAAI,CAAC,IAAI,KAAK,gBAAgB,EAAE,CAAC;oBACjC,MAAM,GAAG,GAAG,mBAAmB,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;oBAChD,MAAM,KAAK,GAAG,mBAAmB,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;oBACpD,OAAO,GAAG,GAAG,KAAK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KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC,GAAG,CAAC;QAC1E,CAAC;QACD,OAAO,CAAC,CAAC,CAAC;YACN,yFAAyF;YACzF,OAAO,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC,GAAG,CAAC;QAC1E,CAAC;IACL,CAAC;AACL,CAAC,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
export const findAxiosClients = (chunks) => {
|
|
3
|
+
let axiosExportedTo = [];
|
|
4
|
+
let axiosImportedTo = {};
|
|
5
|
+
// first get those which have axios client
|
|
6
|
+
for (const chunkName of Object.keys(chunks)) {
|
|
7
|
+
if (chunks[chunkName].isAxiosClient) {
|
|
8
|
+
axiosExportedTo.push(chunkName);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
// now, see which ones import those
|
|
12
|
+
for (const chunkName of Object.keys(chunks)) {
|
|
13
|
+
// iterate through the names of the axios clients
|
|
14
|
+
for (const axiosExportFunctionId of axiosExportedTo) {
|
|
15
|
+
// iterate through the imports of the all the chunks, and see which ones have axios clients imported
|
|
16
|
+
for (const importName of chunks[chunkName].imports) {
|
|
17
|
+
if (importName === axiosExportFunctionId) {
|
|
18
|
+
axiosImportedTo[chunkName] = axiosExportFunctionId;
|
|
19
|
+
console.log(chalk.green(`[✓] ${chunkName} imports axios client ${axiosExportFunctionId}`));
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return { axiosExportedTo, axiosImportedTo };
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=findAxiosClients.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"findAxiosClients.js","sourceRoot":"","sources":["../../../../src/map/next_js/resolveAxiosHelpers/findAxiosClients.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC5B,MAAc,EAC2D,EAAE;IAC3E,IAAI,eAAe,GAAa,EAAE,CAAC;IACnC,IAAI,eAAe,GAA8B,EAAE,CAAC;IAEpD,0CAA0C;IAC1C,KAAK,MAAM,SAAS,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;QAC1C,IAAI,MAAM,CAAC,SAAS,CAAC,CAAC,aAAa,EAAE,CAAC;YAClC,eAAe,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACpC,CAAC;IACL,CAAC;IAED,mCAAmC;IACnC,KAAK,MAAM,SAAS,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;QAC1C,iDAAiD;QACjD,KAAK,MAAM,qBAAqB,IAAI,eAAe,EAAE,CAAC;YAClD,oGAAoG;YACpG,KAAK,MAAM,UAAU,IAAI,MAAM,CAAC,SAAS,CAAC,CAAC,OAAO,EAAE,CAAC;gBACjD,IAAI,UAAU,KAAK,qBAAqB,EAAE,CAAC;oBACvC,eAAe,CAAC,SAAS,CAAC,GAAG,qBAAqB,CAAC;oBAEnD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,SAAS,yBAAyB,qBAAqB,EAAE,CAAC,CAAC,CAAC;gBAC/F,CAAC;YACL,CAAC;QACL,CAAC;IACL,CAAC;IAED,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,CAAC;AAChD,CAAC,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import _traverse from "@babel/traverse";
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
const traverse = _traverse.default;
|
|
4
|
+
export const findAxiosInstance = (ast, thirdArg, axiosImportedToChunk, chunkName) => {
|
|
5
|
+
let axiosInstance = "";
|
|
6
|
+
if (thirdArg !== "") {
|
|
7
|
+
traverse(ast, {
|
|
8
|
+
VariableDeclarator(path) {
|
|
9
|
+
if (path.node.id.type === "Identifier") {
|
|
10
|
+
const varName = path.node.id.name;
|
|
11
|
+
const assignmentValue = path.node.init;
|
|
12
|
+
if ((assignmentValue === null || assignmentValue === void 0 ? void 0 : assignmentValue.type) === "CallExpression" &&
|
|
13
|
+
assignmentValue.callee.type === "Identifier" &&
|
|
14
|
+
assignmentValue.callee.name === thirdArg) {
|
|
15
|
+
const firstArg = assignmentValue.arguments[0];
|
|
16
|
+
if (firstArg && (firstArg.type === "StringLiteral" || firstArg.type === "NumericLiteral")) {
|
|
17
|
+
const thisFunctionAssignmentValue = firstArg.value.toString();
|
|
18
|
+
if (thisFunctionAssignmentValue === axiosImportedToChunk) {
|
|
19
|
+
console.log(chalk.green(`[✓] ${chunkName} uses axios client initialized in ${varName}`));
|
|
20
|
+
axiosInstance = varName;
|
|
21
|
+
path.stop();
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
return axiosInstance;
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=findAxiosInstance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"findAxiosInstance.js","sourceRoot":"","sources":["../../../../src/map/next_js/resolveAxiosHelpers/findAxiosInstance.ts"],"names":[],"mappings":"AACA,OAAO,SAAS,MAAM,iBAAiB,CAAC;AACxC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,MAAM,QAAQ,GAAG,SAAS,CAAC,OAAO,CAAC;AAEnC,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC7B,GAAS,EACT,QAAgB,EAChB,oBAA4B,EAC5B,SAAiB,EACX,EAAE;IACR,IAAI,aAAa,GAAG,EAAE,CAAC;IAEvB,IAAI,QAAQ,KAAK,EAAE,EAAE,CAAC;QAClB,QAAQ,CAAC,GAAG,EAAE;YACV,kBAAkB,CAAC,IAAI;gBACnB,IAAI,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;oBACrC,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC;oBAClC,MAAM,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;oBACvC,IACI,CAAA,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAE,IAAI,MAAK,gBAAgB;wBAC1C,eAAe,CAAC,MAAM,CAAC,IAAI,KAAK,YAAY;wBAC5C,eAAe,CAAC,MAAM,CAAC,IAAI,KAAK,QAAQ,EAC1C,CAAC;wBACC,MAAM,QAAQ,GAAG,eAAe,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;wBAC9C,IAAI,QAAQ,IAAI,CAAC,QAAQ,CAAC,IAAI,KAAK,eAAe,IAAI,QAAQ,CAAC,IAAI,KAAK,gBAAgB,CAAC,EAAE,CAAC;4BACxF,MAAM,2BAA2B,GAAG,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;4BAC9D,IAAI,2BAA2B,KAAK,oBAAoB,EAAE,CAAC;gCACvD,OAAO,CAAC,GAAG,CACP,KAAK,CAAC,KAAK,CAAC,OAAO,SAAS,qCAAqC,OAAO,EAAE,CAAC,CAC9E,CAAC;gCACF,aAAa,GAAG,OAAO,CAAC;gCACxB,IAAI,CAAC,IAAI,EAAE,CAAC;4BAChB,CAAC;wBACL,CAAC;oBACL,CAAC;gBACL,CAAC;YACL,CAAC;SACJ,CAAC,CAAC;IACP,CAAC;IAED,OAAO,aAAa,CAAC;AACzB,CAAC,CAAC"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import _traverse from "@babel/traverse";
|
|
2
|
+
import * as fs from "fs";
|
|
3
|
+
import * as fsPath from "path";
|
|
4
|
+
import chalk from "chalk";
|
|
5
|
+
import * as globals from "../../../utility/globals.js";
|
|
6
|
+
import { astNodeToJsonString } from "./astNodeToJsonString.js";
|
|
7
|
+
import { resolveNodeValue } from "../utils.js";
|
|
8
|
+
const traverse = _traverse.default;
|
|
9
|
+
const findLineNumberByContent = (fileContent, targetLineContent) => {
|
|
10
|
+
const lines = fileContent.split("\n");
|
|
11
|
+
const trimmedTarget = targetLineContent.trim();
|
|
12
|
+
for (let i = 0; i < lines.length; i++) {
|
|
13
|
+
if (lines[i].trim() === trimmedTarget) {
|
|
14
|
+
return i + 1;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return 0;
|
|
18
|
+
};
|
|
19
|
+
export const handleAxiosCreate = (path, ast, chunkCode, directory, chunkName, chunks) => {
|
|
20
|
+
let axiosCreateVarName = "";
|
|
21
|
+
let axiosCreateLineNumber = 0;
|
|
22
|
+
if (path.parentPath.isCallExpression() && path.parentPath.parentPath.isVariableDeclarator()) {
|
|
23
|
+
const varDeclarator = path.parentPath.parentPath.node;
|
|
24
|
+
if (varDeclarator.id.type === "Identifier") {
|
|
25
|
+
axiosCreateVarName = varDeclarator.id.name;
|
|
26
|
+
const axiosCreateLineContent = chunkCode.split("\n")[varDeclarator.loc.start.line - 1];
|
|
27
|
+
const chunkFile = fs.readFileSync(fsPath.join(directory, chunks[chunkName].file), "utf-8");
|
|
28
|
+
axiosCreateLineNumber = findLineNumberByContent(chunkFile, axiosCreateLineContent);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
if (axiosCreateVarName !== "") {
|
|
32
|
+
console.log(chalk.magenta(`[✓] axios.create() assigned to '${axiosCreateVarName}' in chunk ${chunkName} ("${directory}/${chunks[chunkName].file}":${axiosCreateLineNumber})`));
|
|
33
|
+
traverse(ast, {
|
|
34
|
+
CallExpression(callPath) {
|
|
35
|
+
if (callPath.node.callee.type === "Identifier" && callPath.node.callee.name === axiosCreateVarName) {
|
|
36
|
+
const axiosCreateLineContent = chunkCode.split("\n")[callPath.node.loc.start.line - 1];
|
|
37
|
+
const chunkFile = fs.readFileSync(fsPath.join(directory, chunks[chunkName].file), "utf-8");
|
|
38
|
+
const axiosCreateCallLineNumber = findLineNumberByContent(chunkFile, axiosCreateLineContent);
|
|
39
|
+
// if there are no arguments, return
|
|
40
|
+
if (callPath.node.arguments && callPath.node.arguments.length === 0) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const firstArg = callPath.node.arguments[0];
|
|
44
|
+
let axiosCreateCallUrl;
|
|
45
|
+
let axiosCreateCallMethod;
|
|
46
|
+
let axiosCreateCallParams;
|
|
47
|
+
let axiosCreateCallHeaders;
|
|
48
|
+
console.log(chalk.blue(`[+] Found axios.create() call in chunk ${chunkName} ("${directory}/${chunks[chunkName].file}":${axiosCreateCallLineNumber})`));
|
|
49
|
+
if (firstArg.type === "ObjectExpression") {
|
|
50
|
+
for (const property of firstArg.properties) {
|
|
51
|
+
if (property.type === "ObjectProperty" && property.key.type === "Identifier") {
|
|
52
|
+
if (property.key.name === "url") {
|
|
53
|
+
if (property.value.type === "StringLiteral") {
|
|
54
|
+
axiosCreateCallUrl = property.value.value;
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
const scope = callPath.scope;
|
|
58
|
+
const nodeCode = chunkCode.slice(property.value.start, property.value.end);
|
|
59
|
+
axiosCreateCallUrl = resolveNodeValue(property.value, scope, nodeCode, "axios");
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
else if (property.key.name === "method" && property.value.type === "StringLiteral") {
|
|
63
|
+
axiosCreateCallMethod = property.value.value;
|
|
64
|
+
}
|
|
65
|
+
else if (property.key.name === "params") {
|
|
66
|
+
axiosCreateCallParams = astNodeToJsonString(property.value, chunkCode);
|
|
67
|
+
}
|
|
68
|
+
else if (property.key.name === "headers") {
|
|
69
|
+
if (property.value.type === "ObjectExpression") {
|
|
70
|
+
axiosCreateCallHeaders = astNodeToJsonString(property.value, chunkCode);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
if (axiosCreateCallUrl)
|
|
77
|
+
console.log(chalk.green(` URL: ${axiosCreateCallUrl}`));
|
|
78
|
+
if (axiosCreateCallMethod)
|
|
79
|
+
console.log(chalk.green(` Method: ${axiosCreateCallMethod.toUpperCase()}`));
|
|
80
|
+
if (axiosCreateCallParams)
|
|
81
|
+
console.log(chalk.green(` Params: ${axiosCreateCallParams}`));
|
|
82
|
+
if (axiosCreateCallHeaders)
|
|
83
|
+
console.log(chalk.green(` Headers: ${axiosCreateCallHeaders}`));
|
|
84
|
+
globals.addOpenapiOutput({
|
|
85
|
+
url: axiosCreateCallUrl || "",
|
|
86
|
+
method: axiosCreateCallMethod || "",
|
|
87
|
+
path: axiosCreateCallUrl || "",
|
|
88
|
+
headers: axiosCreateCallHeaders || {},
|
|
89
|
+
body: axiosCreateCallParams || "",
|
|
90
|
+
chunkId: chunkName,
|
|
91
|
+
functionFile: `${directory}/${chunks[chunkName].file}`,
|
|
92
|
+
functionFileLine: axiosCreateCallLineNumber,
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
});
|
|
97
|
+
return true; // Indicates that this was an axios.create() call and was handled.
|
|
98
|
+
}
|
|
99
|
+
return false;
|
|
100
|
+
};
|
|
101
|
+
//# sourceMappingURL=handleAxiosCreate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handleAxiosCreate.js","sourceRoot":"","sources":["../../../../src/map/next_js/resolveAxiosHelpers/handleAxiosCreate.ts"],"names":[],"mappings":"AAEA,OAAO,SAAS,MAAM,iBAAiB,CAAC;AACxC,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,MAAM,MAAM,MAAM,CAAC;AAC/B,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,OAAO,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,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