diff --git a/.github/workflows/CodeQLAdvanced.yml b/.github/workflows/CodeQLAdvanced.yml index 4a70a407..e9a8ea1a 100644 --- a/.github/workflows/CodeQLAdvanced.yml +++ b/.github/workflows/CodeQLAdvanced.yml @@ -17,25 +17,15 @@ on: pull_request: branches: [ "dev", "main", "dependabot" ] schedule: - - cron: '16 1 * * 5' + - cron: '16 1 * * 5' # 每周五凌晨1:16运行 jobs: analyze: name: Analyze (${{ matrix.language }}) - # Runner size impacts CodeQL analysis time. To learn more, please see: - # - https://gh.io/recommended-hardware-resources-for-running-codeql - # - https://gh.io/supported-runners-and-hardware-resources - # - https://gh.io/using-larger-runners (GitHub.com only) - # Consider using larger runners or machines with greater resources for possible analysis time improvements. runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }} permissions: - # required for all workflows security-events: write - - # required to fetch internal or private CodeQL packs packages: read - - # only required for workflows in private repositories actions: read contents: read @@ -43,58 +33,43 @@ jobs: fail-fast: false matrix: include: - - language: actions - build-mode: none - - language: java-kotlin - build-mode: none # This mode only analyzes Java. Set this to 'autobuild' or 'manual' to analyze Kotlin too. - # CodeQL supports the following values keywords for 'language': 'actions', 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'rust', 'swift' - # Use `c-cpp` to analyze code written in C, C++ or both - # Use 'java-kotlin' to analyze code written in Java, Kotlin or both - # Use 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both - # To learn more about changing the languages that are analyzed or customizing the build mode for your analysis, - # see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning. - # If you are analyzing a compiled language, you can modify the 'build-mode' for that language to customize how - # your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages + - language: actions + build-mode: none + - language: java-kotlin + build-mode: autobuild # 改为 autobuild 以更好地处理 Kotlin 和 Java 编译:cite[1] + steps: - name: Checkout repository uses: actions/checkout@v4 - # Add any setup steps before running the `github/codeql-action/init` action. - # This includes steps like installing compilers or runtimes (`actions/setup-node` - # or others). This is typically only required for manual builds. - # - name: Setup runtime (example) - # uses: actions/setup-example@v1 - - # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@v3 + uses: github/codeql-action/init@v3 # 更新到最新v3版本 with: languages: ${{ matrix.language }} build-mode: ${{ matrix.build-mode }} - # If you wish to specify custom queries, you can do so here or in a config file. - # By default, queries listed here will override any specified in a config file. - # Prefix the list here with "+" to use these queries and those in the config file. + # 考虑添加自定义查询包或查询套件(如有需要) + # queries: security-and-quality, security-extended + # 或使用配置文件 + # config-file: ./.github/codeql/codeql-config.yml - # For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs - # queries: security-extended,security-and-quality + # 仅为需要编译的语言添加构建步骤 + - name: Setup Java (for Java/Kotlin analysis) + if: matrix.language == 'java-kotlin' + uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: '11' - # If the analyze step fails for one of the languages you are analyzing with - # "We were unable to automatically build your code", modify the matrix above - # to set the build mode to "manual" for that language. Then modify this step - # to build your code. - # ℹ️ Command-line programs to run using the OS shell. - # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun - - if: matrix.build-mode == 'manual' - shell: bash - run: | - echo 'If you are using a "manual" build mode for one or more of the' \ - 'languages you are analyzing, replace this with the commands to build' \ - 'your code, for example:' - echo ' make bootstrap' - echo ' make release' - exit 1 + - name: Build with Maven (for Java/Kotlin analysis) + if: matrix.language == 'java-kotlin' && matrix.build-mode == 'manual' + run: mvn clean compile -q - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v3 with: + # category 可用于区分不同分析任务的结果 category: "/language:${{matrix.language}}" + # 显示设置输出文件格式和名称(可选,但更清晰) + output: codeql-results-${{ matrix.language }}.sarif + # 如果希望发现安全问题时依然上传结果而非失败,可设置以下选项(可选) + # continue-on-error: true diff --git a/meta-bom/pom.xml b/meta-bom/pom.xml new file mode 100644 index 00000000..e1e46744 --- /dev/null +++ b/meta-bom/pom.xml @@ -0,0 +1,51 @@ + + 4.0.0 + + com.acanx.meta + meta-open + ${revision} + ../pom.xml + + com.acanx.meta + meta-bom + ${revision} + pom + Meta-BOM + Meta-BOM POM + https://github.com/ACANX/MetaOpen + + + + bom-graalvm + + + + + + + com.acanx.meta + os-dependencies + ${revision} + pom + import + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + ${java.version} + ${java.version} + ${java.version} + ${project.build.sourceEncoding} + + + + + + diff --git a/meta-component/bom-graalvm/pom.xml b/meta-component/bom-graalvm/pom.xml index bff36ff9..17a3994a 100644 --- a/meta-component/bom-graalvm/pom.xml +++ b/meta-component/bom-graalvm/pom.xml @@ -8,7 +8,7 @@ com.acanx.meta.component bom-graalvm - 21.0.0.0-SNAPSHOT + 21.0.0.1 pom BOM-GraalVM GraalVM Component BOM diff --git a/meta-component/sdk-maven-artifact/pom.xml b/meta-component/sdk-maven-artifact/pom.xml index 5b6ebc44..ebc5a385 100644 --- a/meta-component/sdk-maven-artifact/pom.xml +++ b/meta-component/sdk-maven-artifact/pom.xml @@ -9,7 +9,7 @@ com.acanx.meta.component sdk-maven-artifact - 0.2.1 + ${revision} jar SDK-Maven-Artifact Maven-Artifact SDK Module @@ -25,7 +25,7 @@ com.acanx.meta.model model-maven - 0.3.9 + ${revision} com.acanx.meta.model diff --git a/meta-model/model-deepseek/pom.xml b/meta-model/model-deepseek/pom.xml index df55d069..e1033885 100644 --- a/meta-model/model-deepseek/pom.xml +++ b/meta-model/model-deepseek/pom.xml @@ -9,7 +9,7 @@ com.acanx.meta.model model-deepseek - 0.2.0-SNAPSHOT + ${revision} jar Model-DeepSeek DeepSeek Model Module diff --git a/meta-model/model-maven/src/test/java/com/acanx/meta/model/AppTest.java b/meta-model/model-deepseek/src/test/java/com/acanx/meta/model/deepseek/AppTest.java similarity index 87% rename from meta-model/model-maven/src/test/java/com/acanx/meta/model/AppTest.java rename to meta-model/model-deepseek/src/test/java/com/acanx/meta/model/deepseek/AppTest.java index 3b4b535d..d162f7f5 100644 --- a/meta-model/model-maven/src/test/java/com/acanx/meta/model/AppTest.java +++ b/meta-model/model-deepseek/src/test/java/com/acanx/meta/model/deepseek/AppTest.java @@ -1,4 +1,4 @@ -package com.acanx.meta.model; +package com.acanx.meta.model.deepseek; import org.junit.jupiter.api.Assertions; diff --git a/meta-model/model-dingtalk/pom.xml b/meta-model/model-dingtalk/pom.xml index b82a82bb..a0519428 100644 --- a/meta-model/model-dingtalk/pom.xml +++ b/meta-model/model-dingtalk/pom.xml @@ -9,7 +9,7 @@ com.acanx.meta.model model-dingtalk - 0.2.0-SNAPSHOT + ${revision} jar Model-Dingtalk Dingtalk Model Module diff --git a/meta-model/model-test/src/test/java/com/acanx/meta/model/AppTest.java b/meta-model/model-dingtalk/src/test/java/com/acanx/meta/model/dingtalk/AppTest.java similarity index 87% rename from meta-model/model-test/src/test/java/com/acanx/meta/model/AppTest.java rename to meta-model/model-dingtalk/src/test/java/com/acanx/meta/model/dingtalk/AppTest.java index 3b4b535d..9421e73a 100644 --- a/meta-model/model-test/src/test/java/com/acanx/meta/model/AppTest.java +++ b/meta-model/model-dingtalk/src/test/java/com/acanx/meta/model/dingtalk/AppTest.java @@ -1,4 +1,4 @@ -package com.acanx.meta.model; +package com.acanx.meta.model.dingtalk; import org.junit.jupiter.api.Assertions; diff --git a/meta-model/model-maven/pom.xml b/meta-model/model-maven/pom.xml index 2a50c213..51c103e2 100644 --- a/meta-model/model-maven/pom.xml +++ b/meta-model/model-maven/pom.xml @@ -9,7 +9,7 @@ com.acanx.meta.model model-maven - 0.1.0 + ${revision} jar model-maven https://acanx.com diff --git a/meta-model/model-dingtalk/src/test/java/com/acanx/meta/model/AppTest.java b/meta-model/model-maven/src/test/java/com/acanx/meta/model/maven/AppTest.java similarity index 88% rename from meta-model/model-dingtalk/src/test/java/com/acanx/meta/model/AppTest.java rename to meta-model/model-maven/src/test/java/com/acanx/meta/model/maven/AppTest.java index 3b4b535d..db8424b8 100644 --- a/meta-model/model-dingtalk/src/test/java/com/acanx/meta/model/AppTest.java +++ b/meta-model/model-maven/src/test/java/com/acanx/meta/model/maven/AppTest.java @@ -1,4 +1,4 @@ -package com.acanx.meta.model; +package com.acanx.meta.model.maven; import org.junit.jupiter.api.Assertions; diff --git a/meta-model/model-quote/pom.xml b/meta-model/model-quote/pom.xml index fc2b8fd7..5419891f 100644 --- a/meta-model/model-quote/pom.xml +++ b/meta-model/model-quote/pom.xml @@ -9,7 +9,7 @@ com.acanx.meta.model model-quote - 0.1.6 + ${revision} jar Quote Model Module https://github.com/ACANX/MetaOpen diff --git a/meta-model/model-quote/src/test/java/com/acanx/meta/model/AppTest.java b/meta-model/model-quote/src/test/java/com/acanx/meta/model/quote/AppTest.java similarity index 100% rename from meta-model/model-quote/src/test/java/com/acanx/meta/model/AppTest.java rename to meta-model/model-quote/src/test/java/com/acanx/meta/model/quote/AppTest.java diff --git a/meta-model/model-security/pom.xml b/meta-model/model-security/pom.xml index 8e720bbd..f32752dc 100644 --- a/meta-model/model-security/pom.xml +++ b/meta-model/model-security/pom.xml @@ -9,7 +9,7 @@ com.acanx.meta.model model-security - 0.2.0-SNAPSHOT + ${revision} jar Model-Security Security Model Module diff --git a/meta-model/model-sonatype/pom.xml b/meta-model/model-sonatype/pom.xml index 84b89b03..b1a7ad08 100644 --- a/meta-model/model-sonatype/pom.xml +++ b/meta-model/model-sonatype/pom.xml @@ -9,7 +9,7 @@ com.acanx.meta.model model-sonatype - 0.2.0 + ${revision} jar SonaType Model Module https://acanx.com diff --git a/meta-model/model-sonatype/src/test/java/com/acanx/meta/model/AppTest.java b/meta-model/model-sonatype/src/test/java/com/acanx/meta/model/sonatype/AppTest.java similarity index 100% rename from meta-model/model-sonatype/src/test/java/com/acanx/meta/model/AppTest.java rename to meta-model/model-sonatype/src/test/java/com/acanx/meta/model/sonatype/AppTest.java diff --git a/meta-model/model-test/pom.xml b/meta-model/model-test/pom.xml index e930fd17..c4311181 100644 --- a/meta-model/model-test/pom.xml +++ b/meta-model/model-test/pom.xml @@ -9,7 +9,7 @@ com.acanx.meta.model model-test - 0.2.0-SNAPSHOT + ${revision} jar Model-Test Meta Test Model Module diff --git a/meta-model/model-deepseek/src/test/java/com/acanx/meta/model/AppTest.java b/meta-model/model-test/src/test/java/com/acanx/meta/model/test/AppTest.java similarity index 88% rename from meta-model/model-deepseek/src/test/java/com/acanx/meta/model/AppTest.java rename to meta-model/model-test/src/test/java/com/acanx/meta/model/test/AppTest.java index 3b4b535d..84427269 100644 --- a/meta-model/model-deepseek/src/test/java/com/acanx/meta/model/AppTest.java +++ b/meta-model/model-test/src/test/java/com/acanx/meta/model/test/AppTest.java @@ -1,4 +1,4 @@ -package com.acanx.meta.model; +package com.acanx.meta.model.test; import org.junit.jupiter.api.Assertions; diff --git a/meta-model/model-test/src/test/java/com/acanx/meta/model/test/DuplicateClassCheck.java b/meta-model/model-test/src/test/java/com/acanx/meta/model/test/DuplicateClassCheck.java new file mode 100644 index 00000000..2bd3d49a --- /dev/null +++ b/meta-model/model-test/src/test/java/com/acanx/meta/model/test/DuplicateClassCheck.java @@ -0,0 +1,183 @@ +package com.acanx.meta.model.test; + +import java.io.File; +import java.io.IOException; +import java.nio.file.FileVisitResult; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.SimpleFileVisitor; +import java.nio.file.attribute.BasicFileAttributes; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * DuplicateClassCheck + * + * @author ACANX + * @since 20250901 + */ +public class DuplicateClassCheck { + // 存储类名与对应文件路径的映射 + private static Map> classMap = new HashMap<>(); + + public static void main(String[] args) { +// if (args.length == 0) { +// System.out.println("请提供Maven项目的根目录路径作为参数"); +// System.out.println("用法: java DuplicateClassDetector <项目根目录>"); +// return; +// } + String projectRoot = "D:/Code/JavaCode/MetaOpen"; + System.out.println("开始扫描项目: " + projectRoot); + try { + // 扫描项目中的所有类文件 + scanProject(projectRoot); + // 检测并报告重复的类 + detectAndReportDuplicates(); + } catch (IOException e) { + System.err.println("扫描过程中发生错误: " + e.getMessage()); + e.printStackTrace(); + } + } + + /** + * 扫描项目中的所有类文件 + */ + private static void scanProject(String projectRoot) throws IOException { + Path startPath = Paths.get(projectRoot); + System.out.println(startPath.toAbsolutePath().toString()); + Files.walkFileTree(startPath, new SimpleFileVisitor() { + @Override + public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) { + if (isClassFile(file)) { + System.out.println(file.toAbsolutePath().toString()); + processClassFile(file, startPath); + } + return FileVisitResult.CONTINUE; + } + @Override + public FileVisitResult visitFileFailed(Path file, IOException exc) { + System.err.println("无法访问文件: " + file + ": " + exc.getMessage()); + return FileVisitResult.CONTINUE; + } + }); + } + + /** + * 判断文件是否为类文件 + */ + private static boolean isClassFile(Path file) { + String fileName = file.toString(); + return fileName.endsWith(".class") || fileName.endsWith(".java"); + } + + /** + * 处理类文件,提取类名并记录到映射中 + */ + private static void processClassFile(Path file, Path projectRoot) { + try { + // 获取相对于项目根目录的路径 + Path relativePath = projectRoot.relativize(file); + + // 根据文件类型提取类名 + String className = extractClassName(file, relativePath); + System.out.println(className); + if (className != null && !className.isEmpty()) { + // 将类名和文件路径添加到映射中 + if (!classMap.containsKey(className)) { + classMap.put(className, new ArrayList<>()); + } + classMap.get(className).add(relativePath.toString()); + } + } catch (Exception e) { + System.err.println("处理文件时出错: " + file + ": " + e.getMessage()); + } + } + + /** + * 从文件路径中提取类名 + */ + private static String extractClassName(Path file, Path relativePath) { + String fileName = file.toString(); + if (fileName.endsWith(".class")) { + // 对于.class文件,从文件路径推断类名 + return extractClassNameFromClassFile(relativePath); + } else + if (fileName.endsWith(".java")) { + // 对于.java文件,从文件路径推断类名 + return extractClassNameFromJavaFile(relativePath); + } + System.out.println(file.toAbsolutePath().toString()); + return null; + } + + /** + * 从.class文件路径提取类名 + */ + private static String extractClassNameFromClassFile(Path relativePath) { + String pathStr = relativePath.toString(); + + // 移除开头的target/classes/或target/test-classes/ + if (pathStr.indexOf("target\\classes\\") >=0 ) { + pathStr = pathStr.substring(pathStr.indexOf("target\\classes\\")+15); + // System.out.println(pathStr); + } else if (pathStr.indexOf("target\\test-classes\\") >=0 ) { + pathStr = pathStr.substring(pathStr.indexOf("target\\test-classes\\")+15); + // System.out.println(pathStr); + } + + // 将路径分隔符替换为.,并移除.class后缀 + return pathStr.replace(File.separatorChar, '.') + .replace(".class", ""); + } + + /** + * 从.java文件路径提取类名 + */ + private static String extractClassNameFromJavaFile(Path relativePath) { + String pathStr = relativePath.toString(); + // System.out.println("pathStr: " + pathStr); + // 移除开头的src/main/java/或src/test/java/ + if (pathStr.indexOf("src\\main\\java\\") >=0 ) { + pathStr = pathStr.substring(pathStr.indexOf("src\\main\\java\\")+14); + // System.out.println(pathStr); + } else if (pathStr.indexOf("src\\test\\java\\") >=0 ) { + pathStr = pathStr.substring(pathStr.indexOf("src\\test\\java\\")+14); + // System.out.println(pathStr); + } else { + System.out.println("=============" + pathStr); + } + // 将路径分隔符替换为.,并移除.java后缀 + return pathStr.replace(File.separatorChar, '.').replace(".java", ""); + } + + /** + * 检测并报告重复的类 + */ + private static void detectAndReportDuplicates() { + boolean hasDuplicates = false; + + for (Map.Entry> entry : classMap.entrySet()) { + String className = entry.getKey(); + List filePaths = entry.getValue(); + + if (filePaths.size() > 1) { + hasDuplicates = true; + System.out.println("\n发现重复类: " + className); + System.out.println("出现位置:"); + + for (String path : filePaths) { + System.out.println(" - " + path); + } + } + } + + if (!hasDuplicates) { + System.out.println("未发现重复类"); + } else { + System.out.println("\n扫描完成,发现重复类!"); + } + } +} diff --git a/meta-model/model-wechat-work/pom.xml b/meta-model/model-wechat-work/pom.xml index d07a2e63..9a05c445 100644 --- a/meta-model/model-wechat-work/pom.xml +++ b/meta-model/model-wechat-work/pom.xml @@ -9,7 +9,7 @@ com.acanx.meta.model model-wechat-work - 0.2.0-SNAPSHOT + ${revision} jar Model-Wechat-Work WeChat-Work Model Module diff --git a/meta-model/model-wechat-work/src/test/java/com/acanx/meta/model/AppTest.java b/meta-model/model-wechat-work/src/test/java/com/acanx/meta/model/wechat/work/AppTest.java similarity index 100% rename from meta-model/model-wechat-work/src/test/java/com/acanx/meta/model/AppTest.java rename to meta-model/model-wechat-work/src/test/java/com/acanx/meta/model/wechat/work/AppTest.java diff --git a/meta-model/pom.xml b/meta-model/pom.xml index 46674e35..c53d6ee0 100644 --- a/meta-model/pom.xml +++ b/meta-model/pom.xml @@ -17,14 +17,14 @@ UTF-8 - - - - - - - - + model-security + model-quote + model-sonatype + model-wechat-work + model-dingtalk + model-deepseek + model-test + model-maven