Files
hack/tools/scripts/llm-key-hunter/results/_cache/content/caohch-1_themis.json
T

1 line
17 KiB
JSON
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{"repo": "caohch-1/themis", "files": {"themis-static/src/main/java/io/themis/staticanalysis/extraction/address/PropertyChecker.java": {"803dad70e706cf2fade4c4516a4468cb20c03058": {"t": 1785745679.5877254, "n": 4941, "h": "e584ef59c8b9a032", "c": "package indi.dc.extraction.address;\r\nimport java.io.*;\r\n\r\nimport cn.ac.ios.bridge.util.Log;\r\nimport org.apache.http.client.methods.*;\r\nimport org.apache.http.entity.StringEntity;\r\nimport org.apache.http.impl.client.CloseableHttpClient;\r\nimport org.apache.http.impl.client.HttpClients;\r\nimport com.google.gson.*;\r\nimport org.apache.http.util.EntityUtils;\r\n\r\npublic class PropertyChecker {\r\n private static final String API_ENDPOINT = \"https://api.deepseek.com/chat/completions\";\r\n private static final Gson gson = new Gson();\r\n\r\n public static String checkIfNetworkProperty(String name, String value, String description) {\r\n try (CloseableHttpClient client = HttpClients.createDefault()) {\r\n HttpPost httpPost = new HttpPost(API_ENDPOINT);\r\n\r\n // 设置请求头\r\n httpPost.setHeader(\"Content-Type\", \"application/json\");\r\n httpPost.setHeader(\"Authorization\", \"Bearer \" + DEEPSEEK_API_KEY);\r\n\r\n // 构建请求体\r\n String requestBody = buildRequestBody(buildPrompt(name, value, description));\r\n httpPost.setEntity(new StringEntity(requestBody));\r\n\r\n // 执行请求\r\n try (CloseableHttpResponse response = client.execute(httpPost)) {\r\n String result = parseResponse(EntityUtils.toString(response.getEntity()));\r\n// Log.i(name, \" \", result);\r\n return result;\r\n }\r\n } catch (Exception e) {\r\n e.printStackTrace();\r\n return \"Neither\";\r\n }\r\n }\r\n\r\n private static String buildPrompt(String name, String value, String description) {\r\n return String.format(\r\n \"Comprehensively analyze whether a Hadoop XML configuration item is an IP Address or Port:\\n\" +\r\n \"Name: %s\\n\" +\r\n \"Value: %s\\n\" +\r\n \"Description: %s\\n\\n\" +\r\n \"Judgment criteria:\\n\" +\r\n \"1. Return ADDRESS if it represents a network location (e.g., IP address, domain name, hostname, etc.)\\n\" +\r\n \"2. Return PORT if it represents a network port\\n\" +\r\n \"3. Return NEITHER if unrelated to network positioning\\n\\n\" +\r\n \"Response format: ADDRESS/PORT/NEITHER (UPPERCASE ONLY, no explanation)\",\r\n name, value, description\r\n );\r\n }\r\n\r\n private static String buildRequestBody(String prompt) {\r\n JsonObject requestBody = new JsonObject();\r\n requestBody.addProperty(\"model\", \"deepseek-chat\");\r\n\r\n JsonArray messages = new JsonArray();\r\n JsonObject message = new JsonObject();\r\n message.addProperty(\"role\", \"user\");\r\n message.addProperty(\"content\", prompt);\r\n messages.add(message);\r\n\r\n requestBody.add(\"messages\", messages);\r\n return gson.toJson(requestBody);\r\n }\r\n\r\n private static String parseResponse(String jsonResponse) {\r\n try {\r\n JsonObject responseJson = gson.fromJson(jsonResponse, JsonObject.class);\r\n String answer = responseJson.getAsJsonArray(\"choices\")\r\n .get(0).getAsJsonObject()\r\n .getAsJsonObject(\"message\")\r\n .get(\"content\").getAsString()\r\n .trim();\r\n return answer;\r\n } catch (Exception e) {\r\n System.err.println(\"响应解析失败: \" + jsonResponse);\r\n return \"Neither\";\r\n }\r\n }\r\n\r\n // 正则表达式检查是否是 IPv4 地址\r\n private static final String IPV4_PATTERN =\r\n \"^(localhost|\" + // localhost匹配\r\n \"(?:(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])\\\\.){3}\" + // IP地址部分\r\n \"(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9]))$\";\r\n\r\n // 支持完整、压缩和混合IPv6表示法(包括::1)\r\n private static final String IPV6_PATTERN =\r\n \"^(\" +\r\n // 完整格式(8组)\r\n \"([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}\" +\r\n \"|\" +\r\n // 压缩格式(含::)\r\n \"(([0-9a-fA-F]{1,4}:){0,6}[0-9a-fA-F]{0,4})?::\" +\r\n \"(([0-9a-fA-F]{1,4}:){0,6}[0-9a-fA-F]{0,4})\" +\r\n \")$\";\r\n\r\n // 正则表达式检查是否是端口号\r\n private static final String PORT_PATTERN = \"^([0-9]{1,5})$\";\r\n\r\n // 判断是否是 IPv4 地址\r\n private static boolean isIPv4(String str) {\r\n return str != null && str.matches(IPV4_PATTERN);\r\n }\r\n\r\n // 增强版IPv6检测(包含::1等缩写形式)\r\n private static boolean isIPv6(String str) {\r\n return str.matches(IPV6_PATTERN) || str.matches(\"^::1$\"); // 明确匹配环回地址\r\n }\r\n\r\n // 判断是否是 IP 地址(包含localhost)\r\n public static boolean isIPAddress(String str) {\r\n if (str == null) return false;\r\n\r\n// // 优先检查特殊名称\r\n// if (str.equalsIgnoreCase(\"localhost\")) {\r\n// return true;\r\n// }\r\n\r\n // 检查IPv4/IPv6格式\r\n return isIPv4(str) || isIPv6(str);\r\n }\r\n\r\n}\r\n\r\n"}, "8023accfdd22c03371b8afd705dc158338e61b06": {"t": 1785755687.5009468, "n": 4941, "h": "e584ef59c8b9a032", "c": "package indi.dc.extraction.address;\r\nimport java.io.*;\r\n\r\nimport cn.ac.ios.bridge.util.Log;\r\nimport org.apache.http.client.methods.*;\r\nimport org.apache.http.entity.StringEntity;\r\nimport org.apache.http.impl.client.CloseableHttpClient;\r\nimport org.apache.http.impl.client.HttpClients;\r\nimport com.google.gson.*;\r\nimport org.apache.http.util.EntityUtils;\r\n\r\npublic class PropertyChecker {\r\n private static final String API_ENDPOINT = \"https://api.deepseek.com/chat/completions\";\r\n private static final Gson gson = new Gson();\r\n\r\n public static String checkIfNetworkProperty(String name, String value, String description) {\r\n try (CloseableHttpClient client = HttpClients.createDefault()) {\r\n HttpPost httpPost = new HttpPost(API_ENDPOINT);\r\n\r\n // 设置请求头\r\n httpPost.setHeader(\"Content-Type\", \"application/json\");\r\n httpPost.setHeader(\"Authorization\", \"Bearer \" + DEEPSEEK_API_KEY);\r\n\r\n // 构建请求体\r\n String requestBody = buildRequestBody(buildPrompt(name, value, description));\r\n httpPost.setEntity(new StringEntity(requestBody));\r\n\r\n // 执行请求\r\n try (CloseableHttpResponse response = client.execute(httpPost)) {\r\n String result = parseResponse(EntityUtils.toString(response.getEntity()));\r\n// Log.i(name, \" \", result);\r\n return result;\r\n }\r\n } catch (Exception e) {\r\n e.printStackTrace();\r\n return \"Neither\";\r\n }\r\n }\r\n\r\n private static String buildPrompt(String name, String value, String description) {\r\n return String.format(\r\n \"Comprehensively analyze whether a Hadoop XML configuration item is an IP Address or Port:\\n\" +\r\n \"Name: %s\\n\" +\r\n \"Value: %s\\n\" +\r\n \"Description: %s\\n\\n\" +\r\n \"Judgment criteria:\\n\" +\r\n \"1. Return ADDRESS if it represents a network location (e.g., IP address, domain name, hostname, etc.)\\n\" +\r\n \"2. Return PORT if it represents a network port\\n\" +\r\n \"3. Return NEITHER if unrelated to network positioning\\n\\n\" +\r\n \"Response format: ADDRESS/PORT/NEITHER (UPPERCASE ONLY, no explanation)\",\r\n name, value, description\r\n );\r\n }\r\n\r\n private static String buildRequestBody(String prompt) {\r\n JsonObject requestBody = new JsonObject();\r\n requestBody.addProperty(\"model\", \"deepseek-chat\");\r\n\r\n JsonArray messages = new JsonArray();\r\n JsonObject message = new JsonObject();\r\n message.addProperty(\"role\", \"user\");\r\n message.addProperty(\"content\", prompt);\r\n messages.add(message);\r\n\r\n requestBody.add(\"messages\", messages);\r\n return gson.toJson(requestBody);\r\n }\r\n\r\n private static String parseResponse(String jsonResponse) {\r\n try {\r\n JsonObject responseJson = gson.fromJson(jsonResponse, JsonObject.class);\r\n String answer = responseJson.getAsJsonArray(\"choices\")\r\n .get(0).getAsJsonObject()\r\n .getAsJsonObject(\"message\")\r\n .get(\"content\").getAsString()\r\n .trim();\r\n return answer;\r\n } catch (Exception e) {\r\n System.err.println(\"响应解析失败: \" + jsonResponse);\r\n return \"Neither\";\r\n }\r\n }\r\n\r\n // 正则表达式检查是否是 IPv4 地址\r\n private static final String IPV4_PATTERN =\r\n \"^(localhost|\" + // localhost匹配\r\n \"(?:(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])\\\\.){3}\" + // IP地址部分\r\n \"(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9]))$\";\r\n\r\n // 支持完整、压缩和混合IPv6表示法(包括::1)\r\n private static final String IPV6_PATTERN =\r\n \"^(\" +\r\n // 完整格式(8组)\r\n \"([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}\" +\r\n \"|\" +\r\n // 压缩格式(含::)\r\n \"(([0-9a-fA-F]{1,4}:){0,6}[0-9a-fA-F]{0,4})?::\" +\r\n \"(([0-9a-fA-F]{1,4}:){0,6}[0-9a-fA-F]{0,4})\" +\r\n \")$\";\r\n\r\n // 正则表达式检查是否是端口号\r\n private static final String PORT_PATTERN = \"^([0-9]{1,5})$\";\r\n\r\n // 判断是否是 IPv4 地址\r\n private static boolean isIPv4(String str) {\r\n return str != null && str.matches(IPV4_PATTERN);\r\n }\r\n\r\n // 增强版IPv6检测(包含::1等缩写形式)\r\n private static boolean isIPv6(String str) {\r\n return str.matches(IPV6_PATTERN) || str.matches(\"^::1$\"); // 明确匹配环回地址\r\n }\r\n\r\n // 判断是否是 IP 地址(包含localhost)\r\n public static boolean isIPAddress(String str) {\r\n if (str == null) return false;\r\n\r\n// // 优先检查特殊名称\r\n// if (str.equalsIgnoreCase(\"localhost\")) {\r\n// return true;\r\n// }\r\n\r\n // 检查IPv4/IPv6格式\r\n return isIPv4(str) || isIPv6(str);\r\n }\r\n\r\n}\r\n\r\n"}, "ccb0ecf87c94dd13746a5cb96d3c04c3f566e7ee": {"t": 1785755688.7287524, "n": 5030, "h": "7d24d46639c3a0c8", "c": "package indi.dc.extraction.address;\r\nimport java.io.*;\r\n\r\nimport cn.ac.ios.bridge.util.Log;\r\nimport org.apache.http.client.methods.*;\r\nimport org.apache.http.entity.StringEntity;\r\nimport org.apache.http.impl.client.CloseableHttpClient;\r\nimport org.apache.http.impl.client.HttpClients;\r\nimport com.google.gson.*;\r\nimport org.apache.http.util.EntityUtils;\r\n\r\npublic class PropertyChecker {\r\n private static final String DEEPSEEK_API_KEY = \"sk-c11c7c71d0cc4d2ba8d64c63e079cb5e\";\r\n private static final String API_ENDPOINT = \"https://api.deepseek.com/chat/completions\";\r\n private static final Gson gson = new Gson();\r\n\r\n public static String checkIfNetworkProperty(String name, String value, String description) {\r\n try (CloseableHttpClient client = HttpClients.createDefault()) {\r\n HttpPost httpPost = new HttpPost(API_ENDPOINT);\r\n\r\n // 设置请求头\r\n httpPost.setHeader(\"Content-Type\", \"application/json\");\r\n httpPost.setHeader(\"Authorization\", \"Bearer \" + DEEPSEEK_API_KEY);\r\n\r\n // 构建请求体\r\n String requestBody = buildRequestBody(buildPrompt(name, value, description));\r\n httpPost.setEntity(new StringEntity(requestBody));\r\n\r\n // 执行请求\r\n try (CloseableHttpResponse response = client.execute(httpPost)) {\r\n String result = parseResponse(EntityUtils.toString(response.getEntity()));\r\n// Log.i(name, \" \", result);\r\n return result;\r\n }\r\n } catch (Exception e) {\r\n e.printStackTrace();\r\n return \"Neither\";\r\n }\r\n }\r\n\r\n private static String buildPrompt(String name, String value, String description) {\r\n return String.format(\r\n \"Comprehensively analyze whether a Hadoop XML configuration item is an IP Address or Port:\\n\" +\r\n \"Name: %s\\n\" +\r\n \"Value: %s\\n\" +\r\n \"Description: %s\\n\\n\" +\r\n \"Judgment criteria:\\n\" +\r\n \"1. Return ADDRESS if it represents a network location (e.g., IP address, domain name, hostname, etc.)\\n\" +\r\n \"2. Return PORT if it represents a network port\\n\" +\r\n \"3. Return NEITHER if unrelated to network positioning\\n\\n\" +\r\n \"Response format: ADDRESS/PORT/NEITHER (UPPERCASE ONLY, no explanation)\",\r\n name, value, description\r\n );\r\n }\r\n\r\n private static String buildRequestBody(String prompt) {\r\n JsonObject requestBody = new JsonObject();\r\n requestBody.addProperty(\"model\", \"deepseek-chat\");\r\n\r\n JsonArray messages = new JsonArray();\r\n JsonObject message = new JsonObject();\r\n message.addProperty(\"role\", \"user\");\r\n message.addProperty(\"content\", prompt);\r\n messages.add(message);\r\n\r\n requestBody.add(\"messages\", messages);\r\n return gson.toJson(requestBody);\r\n }\r\n\r\n private static String parseResponse(String jsonResponse) {\r\n try {\r\n JsonObject responseJson = gson.fromJson(jsonResponse, JsonObject.class);\r\n String answer = responseJson.getAsJsonArray(\"choices\")\r\n .get(0).getAsJsonObject()\r\n .getAsJsonObject(\"message\")\r\n .get(\"content\").getAsString()\r\n .trim();\r\n return answer;\r\n } catch (Exception e) {\r\n System.err.println(\"响应解析失败: \" + jsonResponse);\r\n return \"Neither\";\r\n }\r\n }\r\n\r\n // 正则表达式检查是否是 IPv4 地址\r\n private static final String IPV4_PATTERN =\r\n \"^(localhost|\" + // localhost匹配\r\n \"(?:(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])\\\\.){3}\" + // IP地址部分\r\n \"(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9]))$\";\r\n\r\n // 支持完整、压缩和混合IPv6表示法(包括::1)\r\n private static final String IPV6_PATTERN =\r\n \"^(\" +\r\n // 完整格式(8组)\r\n \"([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}\" +\r\n \"|\" +\r\n // 压缩格式(含::)\r\n \"(([0-9a-fA-F]{1,4}:){0,6}[0-9a-fA-F]{0,4})?::\" +\r\n \"(([0-9a-fA-F]{1,4}:){0,6}[0-9a-fA-F]{0,4})\" +\r\n \")$\";\r\n\r\n // 正则表达式检查是否是端口号\r\n private static final String PORT_PATTERN = \"^([0-9]{1,5})$\";\r\n\r\n // 判断是否是 IPv4 地址\r\n private static boolean isIPv4(String str) {\r\n return str != null && str.matches(IPV4_PATTERN);\r\n }\r\n\r\n // 增强版IPv6检测(包含::1等缩写形式)\r\n private static boolean isIPv6(String str) {\r\n return str.matches(IPV6_PATTERN) || str.matches(\"^::1$\"); // 明确匹配环回地址\r\n }\r\n\r\n // 判断是否是 IP 地址(包含localhost)\r\n public static boolean isIPAddress(String str) {\r\n if (str == null) return false;\r\n\r\n// // 优先检查特殊名称\r\n// if (str.equalsIgnoreCase(\"localhost\")) {\r\n// return true;\r\n// }\r\n\r\n // 检查IPv4/IPv6格式\r\n return isIPv4(str) || isIPv6(str);\r\n }\r\n\r\n}\r\n"}}}}