繁体   English   中英

使用 exec-maven-plugin 运行带有来自 azure 管道的安全令牌的外部程序

[英]Using exec-maven-plugin to run external program with secured token from azure pipeline

这里有很多关于 exec-maven-plugin 的问题,但这是不同的。 我正在尝试使用 exec-maven-plugin 在 maven 中运行具有 exec 目标的外部程序。 要通过的 arguments 之一是在 azure 管道上定义的安全令牌。

问题是,如果我对令牌进行硬编码,这意味着实际令牌值没有保护它并且我运行 mvn exec:exec 命令,它可以工作。 但是当我从 azure 管道传递安全令牌时,它无法与外部程序通信。

有没有办法在将这个安全令牌作为参数传递给 exec-maven-plugin 之前解密它,或者有没有其他方法可以让它工作?

pom的相关部分是:

<groupId>org.codehaus.mojo</groupId>
              <artifactId>exec-maven-plugin</artifactId>
              <version>3.0.0</version>
              <executions>
                  <execution>
                      <phase>package</phase>
                      <goals>
                          <goal>exec</goal>
                      </goals>
                  </execution>
              </executions>
              <configuration>
                  <executable>java</executable>
                  <arguments>
                      <argument>-Djavax.net.ssl.trustStore=$(env.MAVEN_TRUST_STORE)</argument>
                      <argument>-jar</argument>
                      <argument>                            ${settings.localRepository}/com/github/externalprogram/ddd/$(ddd.version)/ddd-$(ddd.version).jar
                      </argument>
                      <argument>--externalprogram.url=https://xxxx.yyyy.com/</argument>
                      <argument>--externalprogram.proxy.host=${someproxy}</argument>
                      <argument>--externalprogram.proxy.port=0000</argument>
                      <argument>--externalprogram.api.token=$**(secure-token)**</argument>
                      <argument>--detect.maven.path=$(env.M2_HOME)/bin/$(mvn)</argument>
                      <argument>--detect.maven.include.plugins=true</argument>
                      <argument>--detect.maven.build.command=-s $(env.MAVEN_SETTINGS_XML) -Djavax.net.ssl.trustStore=$(env.MAVEN_TRUST_STORE)
                      </argument>
                      <argument>--detect.included.detector.types=maven,pip,npm</argument>
                      <argument>
                          --detect.externalprogram.signature.scanner.exclusion.name.patterns=*target*,*/target,*\target
                      </argument>
                      <argument>--detect.bdio2.enabled=false</argument>
                      <argument>--detect.project.version.phase=$(versionPhase)</argument>
                      <argument>--detect.code.location.name=${project.version}</argument>
                  </arguments>
              </configuration>
          </plugin>

因此,如果我用实际值替换安全令牌,它就可以工作。 但是当我使用安全值时,它会失败并出现错误:无法与外部程序通信。 未经授权...

您如何定义安全令牌?

注意: secret 变量默认不传递给环境变量

参考: https://docs.microsoft.com/en-us/azure/devops/pipelines/process/variables?view=azure-devops&tabs=yaml%2Cbatch#secret-variables

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM