lucy-xss-servlet-filter Spring 6 (jakarta servlet)에서 사용 에서 처리한 부분은,
아무래도 개발자 입장에서 찝찝할 수 밖에 없는게 사실이다.
좀 더 깔끔한 적용을 위해 직접 jar 파일을 만드는 법을 서술한다.
자바 17로 컴파일이 되지 않으므로 JDK 11 을 설치하여 진행하도록 한다.
1. 네이버에서 제공하는 lucy-xss-servlet-filter 를 clone 한다.
git clone https://github.com/naver/lucy-xss-servlet-filter.git
2. pom.xml 을 다음과 같이 변경한다.
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<organization>
<name>Naver Labs</name>
<url>http://lab.naver.com/</url>
</organization>
<groupId>com.navercorp.lucy</groupId>
<artifactId>lucy-xss-servlet</artifactId>
<packaging>jar</packaging>
<version>2.0.1</version>
<name>Lucy Xss Servlet Filter</name>
<description>XSS Servlet Filter for Web Service</description>
<parent>
<groupId>org.sonatype.oss</groupId>
<artifactId>oss-parent</artifactId>
<version>7</version>
</parent>
<licenses>
<license>
<name>Apache License Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
</license>
</licenses>
<scm>
<url>https://github.com/naver/lucy-xss-servlet-filter</url>
<connection>scm:git:git://github.com/naver/lucy-xss-servlet-filter.git</connection>
<developerConnection>scm:git:git@github.com:naver/lucy-xss-servlet-filter.git</developerConnection>
<tag>HEAD</tag>
</scm>
<developers>
<developer>
<name>Byeongmin Jeon</name>
<id>todtod80</id>
</developer>
<developer>
<name>Sanghyuk Jung</name>
<id>benelog</id>
</developer>
<developer>
<name>Hyeongkyu Lee</name>
<id>leeplay</id>
</developer>
<developer>
<name>HyunGil Jeong</name>
<id>Xylus</id>
</developer>
</developers>
<properties>
<additionalparam>-Xdoclint:none</additionalparam>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.12.0</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>com.navercorp.lucy</groupId>
<artifactId>lucy-xss</artifactId>
<version>1.6.3</version>
</dependency>
<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<version>6.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>6.0.6</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<sourceDirectory>src/main/java</sourceDirectory>
<resources>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.*</include>
</includes>
</resource>
<resource>
<directory>src/main/java</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
<testResources>
<testResource>
<directory>src/test/resources</directory>
<includes>
<include>**/*.*</include>
</includes>
</testResource>
<testResource>
<directory>src/test/java</directory>
<includes>
<include>**/*.xml</include>
<include>**/*.properties</include>
</includes>
</testResource>
</testResources>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<debug>true</debug>
<optimize>true</optimize>
<encoding>utf-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.1.2</version>
<configuration>
<excludes>
<exclude>**/Mock*</exclude>
<exclude>**/Abstract*</exclude>
<exclude>**/*Helper</exclude>
<exclude>**/*$*</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.3.0</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.6.0</version>
<configuration>
<descriptors>
<descriptor>release.xml</descriptor>
</descriptors>
<finalName>lucy-xss-servlet-${pom.version}</finalName>
<appendAssemblyId>false</appendAssemblyId>
<tarLongFileMode>gnu</tarLongFileMode>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>3.0.5</version>
</plugin>
</plugins>
</pluginManagement>
</build>
<profiles>
<profile>
<id>release-sign-artifacts</id>
<activation>
<property>
<name>performRelease</name>
<value>true</value>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
3. https://god-logger.tistory.com/23 에서 src.zip 내부에 있는 XssEscapeServletFilter.java 와 XssEscapeServletFilterWrapper.java를 clone한 프로젝트 폴더 내부 src.main.java.com.navercorp.lucy.security.xss.servletfilter 로 이동시킨다.
4. pom.xml - maven - Reload Project
5. 프로젝트 설정에서 sdk 와 언어 레벨을 11로 맞춰준다.
6. Artifacts - [+] - JAR - FromModules With Dependencies... 를 클릭한다.
7. OK 를 클릭한다.
8. apply 혹은 ok를 눌러준다.
9. Build (빌드) -> Build Artifects...
10. 아래 빨간박스와 같이 클릭
11. jar 파일 확인
다음 글을 조회하여 완성된 jar 파일을 적용하는 예제를 확인해보자.
lucy-xss-servlet-filter Spring 6 용 JAR 빌드/적용 (2)
'자바 > Spring Framework' 카테고리의 다른 글
스프링 6.1 로 업그레이드시 매개변수,빈 인식 불가현상 (0) | 2023.12.12 |
---|---|
lucy-xss-servlet-filter Spring 6 용 JAR 빌드/적용 (2) (0) | 2023.08.17 |
lucy-xss-servlet-filter Spring 6 (jakarta servlet)에서 사용 (0) | 2023.08.11 |
스프링 프레임워크 6 thymeleaf Layout 설정 (0) | 2023.05.11 |