From 48835348bb4794485328671a11809692416106f4 Mon Sep 17 00:00:00 2001 From: kezhenxu94 Date: Wed, 19 Jun 2019 14:04:22 +0800 Subject: [PATCH] Check disallowed imports in agent instrumentation classes (#2908) * Check disallowed imports in agent instrumentation classes * Remove check script * Remove script --- Jenkinsfile | 8 ----- .../resources/skywalking => }/CHECKSTYLE_HEAD | 0 .../resources/skywalking => }/checkStyle.xml | 7 +++- apm-checkstyle/{pom.xml => importControl.xml} | 23 ++++++------- pom.xml | 14 ++------ .../check/agent/plugin/PluginImportedCheck.sh | 32 ------------------- 6 files changed, 18 insertions(+), 66 deletions(-) rename apm-checkstyle/{src/main/resources/skywalking => }/CHECKSTYLE_HEAD (100%) rename apm-checkstyle/{src/main/resources/skywalking => }/checkStyle.xml (94%) rename apm-checkstyle/{pom.xml => importControl.xml} (56%) delete mode 100755 tools/check/agent/plugin/PluginImportedCheck.sh diff --git a/Jenkinsfile b/Jenkinsfile index 06c86a1c1c..c142573059 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -58,14 +58,6 @@ pipeline { } } - stage('Check agent plugin instrumentation imports') { - steps { - sh './tools/check/agent/plugin/PluginImportedCheck.sh apm-sdk-plugin' - sh './tools/check/agent/plugin/PluginImportedCheck.sh apm-toolkit-activation' - sh './tools/check/agent/plugin/PluginImportedCheck.sh optional-plugins' - } - } - stage('Test & Report') { steps { sh './mvnw -P"agent,backend,ui,dist,CI-with-IT" org.jacoco:jacoco-maven-plugin:0.8.3:prepare-agent clean install org.jacoco:jacoco-maven-plugin:0.8.3:report coveralls:report' diff --git a/apm-checkstyle/src/main/resources/skywalking/CHECKSTYLE_HEAD b/apm-checkstyle/CHECKSTYLE_HEAD similarity index 100% rename from apm-checkstyle/src/main/resources/skywalking/CHECKSTYLE_HEAD rename to apm-checkstyle/CHECKSTYLE_HEAD diff --git a/apm-checkstyle/src/main/resources/skywalking/checkStyle.xml b/apm-checkstyle/checkStyle.xml similarity index 94% rename from apm-checkstyle/src/main/resources/skywalking/checkStyle.xml rename to apm-checkstyle/checkStyle.xml index 913484e561..b1dda82fa4 100644 --- a/apm-checkstyle/src/main/resources/skywalking/checkStyle.xml +++ b/apm-checkstyle/checkStyle.xml @@ -19,7 +19,7 @@ + "http://checkstyle.org/dtds/configuration_1_3.dtd"> @@ -104,5 +104,10 @@ + + + + + diff --git a/apm-checkstyle/pom.xml b/apm-checkstyle/importControl.xml similarity index 56% rename from apm-checkstyle/pom.xml rename to apm-checkstyle/importControl.xml index 5466fa0546..940ea1e56d 100644 --- a/apm-checkstyle/pom.xml +++ b/apm-checkstyle/importControl.xml @@ -1,4 +1,4 @@ - + - - - org.apache - apache - 19 - - - 4.0.0 + - org.apache.skywalking - apm-checkstyle - 6.1.0 - Module to hold Checkstyle for SkyWalking. - + + + + + diff --git a/pom.xml b/pom.xml index dd885473e0..ee9b07c988 100644 --- a/pom.xml +++ b/pom.xml @@ -35,7 +35,6 @@ apm-commons apm-protocol - apm-checkstyle pom @@ -205,7 +204,7 @@ 3.0.1 2.5 4.3.0 - 3.0.0 + 3.1.0 0.8.3 1.21 1.5 @@ -498,16 +497,9 @@ maven-checkstyle-plugin ${maven-checkstyle-plugin.version} - - - org.apache.skywalking - apm-checkstyle - 6.0.0-GA - - - skywalking/checkStyle.xml - skywalking/CHECKSTYLE_HEAD + apm-checkstyle/checkStyle.xml + apm-checkstyle/CHECKSTYLE_HEAD UTF-8 true true diff --git a/tools/check/agent/plugin/PluginImportedCheck.sh b/tools/check/agent/plugin/PluginImportedCheck.sh deleted file mode 100755 index 5084491713..0000000000 --- a/tools/check/agent/plugin/PluginImportedCheck.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh -# ---------------------------------------------------------------------------- -# 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. -# ---------------------------------------------------------------------------- - -plugin_dir=$1 -for dir in `ls "./apm-sniffer/$plugin_dir/"`; do - echo "Scanning $dir" - for f in `find ./apm-sniffer/$plugin_dir/$dir -name *Instrumentation.java `; do - NUM=`head -400 $f | grep ^import |grep -Ev "^import\s+(static\s+)*net.bytebuddy\\." \ - | grep -Ev "^import\s+(static\s+)*org.apache.skywalking\\." |grep -Ev "^import\s+(static\s+)*java\\." | wc -l` - if [ $NUM -gt 0 ] ; then - echo "Plugin: $dir($f), only allow to import JDK and ByteBuddy classes in Instrumentation definition."; - exit 1; - fi - done -done -- GitLab