MCPcopy Index your code
hub / github.com/XF-FS/APIKit / parseApiDocument

Method parseApiDocument

src/main/java/burp/PassiveScanner.java:72–115  ·  view source on GitHub ↗
(final ArrayList<ApiType> apiTypes, final IHttpRequestResponse basePath)

Source from the content-addressed store, hash-verified

70 }
71
72 public List<IScanIssue> parseApiDocument(final ArrayList<ApiType> apiTypes, final IHttpRequestResponse basePath) {
73 ArrayList<IScanIssue> issues = new ArrayList<IScanIssue>();
74 final ExtensionTab extensionTab = BurpExtender.getExtensionTab();
75 for (final ApiType apiType : apiTypes) {
76 Map apiDocuments = apiType.getApiDocuments();
77 for (Object obj : apiDocuments.entrySet()) {
78 @SuppressWarnings("unchecked")
79 Map.Entry<String, IHttpRequestResponse> entry = (Map.Entry<String, IHttpRequestResponse>) obj;
80 new Thread(new Runnable() {
81 @Override
82 public void run() {
83 int num;
84 Object lockObj = PassiveScanner.this.lock;
85 boolean isTargetScan = false;
86 if (apiTypes.size() == 1) {
87 isTargetScan = true;
88 }
89
90 List<ApiEndpoint> apiEndpoints = apiType.parseApiDocument(entry.getValue(), basePath, isTargetScan);
91 apiEndpoints.sort(Comparator.comparing(ApiEndpoint::getUrl));
92 ArrayList<ApiDetailEntity> apiDetails = new ArrayList<>();
93
94 for (ApiEndpoint endpoint : apiEndpoints) {
95 IHttpRequestResponse apiParseRequestResponse = endpoint.getHttpRequestResponse();
96 ApiDetailEntity currentDetail = createApiDetailEntity(endpoint, apiParseRequestResponse, apiType);
97 if (apiParseRequestResponse instanceof HttpRequestResponse) {
98 ((HttpRequestResponse) apiParseRequestResponse).setUpdateAcceptor(currentDetail);
99 }
100 apiDetails.add(currentDetail);
101 }
102
103 synchronized (lockObj) {
104 num = PassiveScanner.this.scannedCount++;
105 }
106 ApiDocumentEntity apiDocument = new ApiDocumentEntity(num, (String) entry.getKey(), BurpExtender.getHelpers().analyzeResponse(((IHttpRequestResponse) entry.getValue()).getResponse()).getStatusCode(), apiType.getApiTypeName(), "true", (IHttpRequestResponse) entry.getValue(), CommonUtils.getCurrentDateTime(), Integer.parseInt(CommonUtils.getContentLength((IHttpRequestResponse) entry.getValue())), apiDetails);
107 extensionTab.addApiDocument(apiDocument);
108 }
109 }).start();
110 }
111 issues.addAll(apiType.exportIssues());
112 BurpExtender.getStdout().print(apiType.exportConsole());
113 }
114 return issues;
115 }
116
117 private ApiDetailEntity createApiDetailEntity(ApiEndpoint endpoint, IHttpRequestResponse response, ApiType apiType) {
118 if (response.getResponse() != null && response.getResponse().length != 0) {

Callers 2

doPassiveScanMethod · 0.95
runMethod · 0.95

Calls 5

getExtensionTabMethod · 0.95
getStdoutMethod · 0.95
getApiDocumentsMethod · 0.65
exportIssuesMethod · 0.65
exportConsoleMethod · 0.65

Tested by

no test coverage detected