github-advanced-security[bot] commented on code in PR #18618:
URL: https://github.com/apache/druid/pull/18618#discussion_r2418066329


##########
web-console/script/check-doc-links.mjs:
##########
@@ -0,0 +1,144 @@
+#!/usr/bin/env node
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* eslint-disable no-undef */
+
+import fs from 'fs';
+import https from 'https';
+import path from 'path';
+import { fileURLToPath } from 'url';
+
+const __dirname = path.dirname(fileURLToPath(import.meta.url));
+
+const DOCS_BASE_URL = 'https://druid.apache.org/docs/latest';
+const SRC_DIR = path.join(__dirname, '../src');
+
+// Regex to find ${getLink('DOCS')}/path patterns
+const DOC_LINK_REGEX = /\$\{getLink\(['"]DOCS['"]\)\}\/([^\s`'"}\]]+)/g;
+
+function getAllTsFiles(dir) {
+  const files = [];
+
+  function traverse(currentPath) {
+    const entries = fs.readdirSync(currentPath, { withFileTypes: true });
+
+    for (const entry of entries) {
+      const fullPath = path.join(currentPath, entry.name);
+
+      if (entry.isDirectory()) {
+        traverse(fullPath);
+      } else if (entry.isFile() && (entry.name.endsWith('.ts') || 
entry.name.endsWith('.tsx'))) {
+        files.push(fullPath);
+      }
+    }
+  }
+
+  traverse(dir);
+  return files;
+}
+
+function extractDocLinks(filePath) {
+  const content = fs.readFileSync(filePath, 'utf-8');
+  const links = [];
+  let match;
+
+  // Reset regex state
+  DOC_LINK_REGEX.lastIndex = 0;
+
+  while ((match = DOC_LINK_REGEX.exec(content)) !== null) {
+    links.push({
+      file: path.relative(path.join(__dirname, '..'), filePath),
+      path: match[1],
+      fullUrl: `${DOCS_BASE_URL}/${match[1]}`
+    });
+  }
+
+  return links;
+}
+
+function checkUrl(url) {
+  return new Promise((resolve) => {
+    https.get(url, { method: 'HEAD' }, (res) => {

Review Comment:
   ## File data in outbound network request
   
   Outbound network request depends on [file data](1).
   
   [Show more 
details](https://github.com/apache/druid/security/code-scanning/10507)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to