新增:测试样例子模块

wuhaoyang
Guo XIn 11 months ago
parent d3a5f15271
commit 94b653de7d
  1. 38
      soanr-keyware-example/.gitignore
  2. 43
      soanr-keyware-example/pom.xml
  3. 0
      soanr-keyware-example/src/main/cxx/.scannerwork/.sonar_lock
  4. 0
      soanr-keyware-example/src/main/cxx/.scannerwork/class-mapping.csv
  5. 6
      soanr-keyware-example/src/main/cxx/.scannerwork/report-task.txt
  6. 0
      soanr-keyware-example/src/main/cxx/ABCVarNameChecker.cc
  7. 48
      soanr-keyware-example/src/main/java/com/keyware/sonar/Main.java
  8. 4
      soanr-keyware-example/src/main/resources/license-header.txt

@ -0,0 +1,38 @@
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### IntelliJ IDEA ###
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws
*.iml
*.ipr
### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/
### Mac OS ###
.DS_Store

@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.keyware.sonar</groupId>
<artifactId>sonar-keyware</artifactId>
<version>1.0</version>
</parent>
<!--<groupId>com.keyware.sonar</groupId>-->
<artifactId>soanr-keyware-example</artifactId>
<version>1.0</version>
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>com.mycila</groupId>
<artifactId>license-maven-plugin</artifactId>
<configuration>
<header>${project.basedir}/src/main/resources/license-header.txt</header>
<!--排除文件-->
<excludes>
<exclude>**/*.properties</exclude>
<exclude>*.sh</exclude>
<exclude>*.yml</exclude>
<exclude>.editorconfig</exclude>
<exclude>.gitignore</exclude>
<exclude>**/*.md</exclude>
<exclude>**/*.xml</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</project>

@ -0,0 +1,6 @@
projectKey=cxx-test
serverUrl=http://localhost:9000
serverVersion=10.2.1.78527
dashboardUrl=http://localhost:9000/dashboard?id=cxx-test
ceTaskId=AYz7dGiT3PoYkLIOzDsz
ceTaskUrl=http://localhost:9000/api/ce/task?id=AYz7dGiT3PoYkLIOzDsz

@ -0,0 +1,48 @@
/*
* Copyright (c) 2023 - 2024. KeyWare.Co.Ltd All rights reserved.
* 项目名称soanr-keyware-example
* 项目描述Parent pom of SonarSource public projects
* 版权说明本软件属北京关键科技股份有限公司所有在未获得北京关键科技股份有限公司正式授权情况下任何企业和个人不能获取阅读安装传播本软件涉及的任何受知识产权保护的内容
*/
package com.keyware.sonar;
import javax.script.Invocable;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
public class Main {
public static void main(String[] args) {
// mvn clean verify sonar:sonar -Dsonar.projectKey=java-test -Dsonar.projectName='java-test' -Dsonar.host.url=http://localhost:9000 -Dsonar.token=sqp_751590ea01a1115ac0c9f10d99fddd2efa09a074
System.out.printf("Hello and welcome!");
int ABC = 1;
for (; ABC <= 5; ABC++) {
System.out.println("i = " + ABC);
}
}
public void loadLibrary(String libraryName, int number) {
String abc = "bac";
System.loadLibrary("/path/to/your/library");
System.loadLibrary(libraryName); // Noncompliant {{在动态加载库前对输入数据进行验证,确保输入数据仅能用于加载允许加载的代码库}}
}
public void dyan() {
String regular = "function regular(args1,args2,args3){................}";
ScriptEngine engine = new ScriptEngineManager().getEngineByName("javascript");
try {
engine.eval(regular); // Noncompliant {{程序设计时禁止动态构建代码进行功能实现}}
if (engine instanceof Invocable) {
Invocable invoke = (Invocable) engine;
String result = (String) invoke.invokeFunction("regular", "");
System.out.println(result);
} else {
System.out.println("error");
}
} catch (ScriptException e) {
System.out.println("表达式runtime错误:" + e.getMessage());
} catch (NoSuchMethodException e) {
throw new RuntimeException(e);
}
}
}

@ -0,0 +1,4 @@
Copyright (c) 2023 - 2024. KeyWare.Co.Ltd All rights reserved.
项目名称:${project.name}
项目描述:${project.description}
版权说明:本软件属北京关键科技股份有限公司所有,在未获得北京关键科技股份有限公司正式授权情况下,任何企业和个人,不能获取、阅读、安装、传播本软件涉及的任何受知识产权保护的内容。
Loading…
Cancel
Save