Skip to content

Commit c46eca1

Browse files
authored
HBASE-28921 Avoid bundling hbase-webapps folder in default jars (#6388) (#6431)
We are bundling all webapp resources in hbase-server, hbase-thrift, hbase-rest and transitively to hbase-shaded-mapreduce jar. This can be an issue, say if any of the Js projects used by hbase are vulnerable, security scan tools like sonatype start flagging the jars too as vulnerable since they contain vulnerable code. With this JIRA, we want to avoid bundling static webapp resources in our jars as these are available during runtime via hbase-webapps directory bundled in our assembly. But, we still need this for our minicluster based tests which expects it to be present in test classpath. Hence, we are copying hbase-webapps to hbase-server tests jar, which contains class SingleProcessHBaseCluster responsible for hbase minicluster creation. This class eventually needs hbase-webapps in classpath during HttpServer initialisation and hence we are adding hbase-webapps to hbase-server test resources. Signed-off-by: Istvan Toth <stoty@apache.org> (cherry picked from commit 16c51d8)
1 parent 8c6247f commit c46eca1

File tree

3 files changed

+93
-15
lines changed

3 files changed

+93
-15
lines changed

hbase-rest/pom.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,15 @@
297297
<skipAssembly>true</skipAssembly>
298298
</configuration>
299299
</plugin>
300+
<plugin>
301+
<groupId>org.apache.maven.plugins</groupId>
302+
<artifactId>maven-jar-plugin</artifactId>
303+
<configuration>
304+
<excludes>
305+
<exclude>**/hbase-webapps/**</exclude>
306+
</excludes>
307+
</configuration>
308+
</plugin>
300309
<!-- General ant tasks, bound to different build phases -->
301310
<plugin>
302311
<artifactId>maven-antrun-plugin</artifactId>

hbase-server/pom.xml

Lines changed: 75 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
<license.bundles.bootstrap>true</license.bundles.bootstrap>
3636
<license.bundles.jquery>true</license.bundles.jquery>
3737
<license.bundles.vega>true</license.bundles.vega>
38+
<hbase.webapps.dir>hbase-webapps</hbase.webapps.dir>
3839
</properties>
3940
<dependencies>
4041
<dependency>
@@ -449,24 +450,83 @@
449450
<skipAssembly>true</skipAssembly>
450451
</configuration>
451452
</plugin>
453+
<plugin>
454+
<groupId>org.codehaus.mojo</groupId>
455+
<artifactId>build-helper-maven-plugin</artifactId>
456+
<executions>
457+
<execution>
458+
<id>add-test-source</id>
459+
<goals>
460+
<goal>add-test-resource</goal>
461+
</goals>
462+
<phase>generate-test-sources</phase>
463+
<configuration>
464+
<!-- Add the hbase-webapps directory to the test resources -->
465+
<resources>
466+
<resource>
467+
<!-- Directory containing hbase-webapps -->
468+
<directory>target/${hbase.webapps.dir}</directory>
469+
<!-- Target directory under test-classes -->
470+
<targetPath>${hbase.webapps.dir}</targetPath>
471+
</resource>
472+
</resources>
473+
</configuration>
474+
</execution>
475+
</executions>
476+
</plugin>
452477
<plugin>
453478
<groupId>org.apache.maven.plugins</groupId>
454479
<artifactId>maven-jar-plugin</artifactId>
455-
<configuration>
456-
<!-- Exclude these 2 packages, because their dependency _binary_ files
457-
include the sources, and Maven 2.2 appears to add them to the sources to compile,
458-
weird -->
459-
<excludes>
460-
<exclude>org/apache/jute/**</exclude>
461-
<exclude>org/apache/zookeeper/**</exclude>
462-
<exclude>**/*.jsp</exclude>
463-
<exclude>hbase-site.xml</exclude>
464-
<exclude>hdfs-site.xml</exclude>
465-
<exclude>log4j.properties</exclude>
466-
<exclude>mapred-queues.xml</exclude>
467-
<exclude>mapred-site.xml</exclude>
468-
</excludes>
469-
</configuration>
480+
<executions>
481+
<!-- Exclude specified file(s) from the default JAR -->
482+
<execution>
483+
<id>default-jar</id>
484+
<goals>
485+
<goal>jar</goal>
486+
</goals>
487+
<phase>package</phase>
488+
<configuration>
489+
<excludes>
490+
<!-- Exclude these 2 packages, because their dependency _binary_ files
491+
include the sources, and Maven 2.2 appears to add them to the sources to compile,
492+
weird -->
493+
<exclude>org/apache/jute/**</exclude>
494+
<exclude>org/apache/zookeeper/**</exclude>
495+
<exclude>**/*.jsp</exclude>
496+
<exclude>hbase-site.xml</exclude>
497+
<exclude>hdfs-site.xml</exclude>
498+
<exclude>log4j.properties</exclude>
499+
<exclude>mapred-queues.xml</exclude>
500+
<exclude>mapred-site.xml</exclude>
501+
<!-- NOTE: We have the below exclude only for the default JAR -->
502+
<exclude>**/hbase-webapps/**</exclude>
503+
</excludes>
504+
</configuration>
505+
</execution>
506+
<!-- Copy of default jar exclusions, minus not removing hbase-webapps-->
507+
<execution>
508+
<id>test-jar</id>
509+
<goals>
510+
<goal>test-jar</goal>
511+
</goals>
512+
<phase>package</phase>
513+
<configuration>
514+
<classifier>tests</classifier>
515+
<excludes>
516+
<exclude>org/apache/jute/**</exclude>
517+
<exclude>org/apache/zookeeper/**</exclude>
518+
<exclude>**/*.jsp</exclude>
519+
<exclude>hbase-site.xml</exclude>
520+
<exclude>hdfs-site.xml</exclude>
521+
<exclude>log4j.properties</exclude>
522+
<exclude>mapred-queues.xml</exclude>
523+
<exclude>mapred-site.xml</exclude>
524+
<!-- We do not want to exclude hbase-webapps from tests. We actually intentionally
525+
add this directory to out test resources. See HBASE-28921 for details! -->
526+
</excludes>
527+
</configuration>
528+
</execution>
529+
</executions>
470530
</plugin>
471531
<!-- General ant tasks, bound to different build phases -->
472532
<plugin>

hbase-thrift/pom.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,15 @@
210210
<skipAssembly>true</skipAssembly>
211211
</configuration>
212212
</plugin>
213+
<plugin>
214+
<groupId>org.apache.maven.plugins</groupId>
215+
<artifactId>maven-jar-plugin</artifactId>
216+
<configuration>
217+
<excludes>
218+
<exclude>**/hbase-webapps/**</exclude>
219+
</excludes>
220+
</configuration>
221+
</plugin>
213222
<!-- General ant tasks, bound to different build phases -->
214223
<plugin>
215224
<artifactId>maven-antrun-plugin</artifactId>

0 commit comments

Comments
 (0)