线上第六期_测试左移代码审计平台 Sonar_20181103

Sonar

安装

docker run -d --name sonarqube \\
-p 9000:9000 -p 9092:9092 \\
registry.docker-cn.com/library/sonarqube

公共演练环境

配置

maven

mvn sonar:sonar \\
  -Dsonar.host.url=http://jenkins.testing-studio.com:9000 \\
  -Dsonar.login=e8a626fc0bac98d8ff1e49723408d7d5d1a73d20

gradle

plugins {
  id "org.sonarqube" version "2.6"
}
./gradlew sonarqube \\
  -Dsonar.host.url=http://jenkins.testing-studio.com:9000 \\
  -Dsonar.login=e8a626fc0bac98d8ff1e49723408d7d5d1a73d20

scanner

https://docs.sonarqube.org/display/SCAN

wget https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-3.2.0.1227.zip

配置<install_directory>/conf/sonar-scanner.properties

sonar.host.url=http://jenkins.testing-studio.com:9000

配置PATH变量

export SONAR_HOME=/Users/seveniruby/temp/sonar/sonar-scanner-3.2.0.1227
export PATH=$SONAR_HOME/bin/:$PATH

示例

git clone https://github.com/SonarSource/sonar-scanning-examples.git

Gradle项目

#https://github.com/testerhome/A-Native-TesterHome.git
git clone https://github.com/testerhome/A-Native-TesterHome.git

增值技术

  • 代码分析技术:Sonar插件 JavaParser anltr
  • class文件分析技术:ASM、ByteBuddy
  • 动态插桩:JavaAgent