|
| 1 | +# Phylum Maven Registry |
| 2 | + |
| 3 | +The Phylum Maven registry is based on [Maven central]. |
| 4 | + |
| 5 | +[Maven central]: https://maven.apache.org/repositories/index.html |
| 6 | + |
| 7 | +## Configuration |
| 8 | + |
| 9 | +All configuration options will require a Phylum API key, since Phylum requires |
| 10 | +authentication. You can find out how to generate one in our |
| 11 | +[API Keys documentation]. |
| 12 | + |
| 13 | +In the following examples, all API keys will be represented as |
| 14 | +`<PHYLUM_API_KEY>`, so make sure to replace them with your generated key. |
| 15 | + |
| 16 | +Additionally, if the default [policy] is not sufficient, a group can be passed |
| 17 | +to evaluate all packages against the group's policy. To do this, just replace |
| 18 | +`<PHYLUM_GROUP>` with the desired group name. The supplied API key **must** have |
| 19 | +access to this group. |
| 20 | + |
| 21 | +If Phylum's default [policy] is sufficient, you can remove all instances of |
| 22 | +`<PHYLUM_GROUP>`. |
| 23 | + |
| 24 | +[API Keys documentation]: ../knowledge_base/api-keys.md#generate-an-api-key |
| 25 | +[policy]: ../knowledge_base/policy.md |
| 26 | + |
| 27 | +### `mvn` |
| 28 | + |
| 29 | +The Phylum authorization header expects a token in Base64, so you first need to |
| 30 | +convert your Phylum group and API key: |
| 31 | + |
| 32 | +```sh |
| 33 | +printf "<PHYLUM_GROUP>:<PHYLUM_API_KEY>" | base64 |
| 34 | +``` |
| 35 | + |
| 36 | +> ⚠️ **WARNING** ⚠️ |
| 37 | +> |
| 38 | +> Do not accidentally save your token into your shell history. |
| 39 | +
|
| 40 | +Custom Maven registries can be configured in the `${user.home}/.m2/settings.xml` |
| 41 | +file. Replace `[BASE64_OUTPUT]` in this XML with the token you've created in the |
| 42 | +previous step: |
| 43 | + |
| 44 | +```xml |
| 45 | +<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" |
| 46 | + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| 47 | + xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 |
| 48 | + http://maven.apache.org/xsd/settings-1.0.0.xsd"> |
| 49 | + <servers> |
| 50 | + <server> |
| 51 | + <id>phylum</id> |
| 52 | + <configuration> |
| 53 | + <httpHeaders> |
| 54 | + <property> |
| 55 | + <name>Authorization</name> |
| 56 | + <value>Basic [BASE64_OUTPUT]</value> |
| 57 | + </property> |
| 58 | + </httpHeaders> |
| 59 | + </configuration> |
| 60 | + </server> |
| 61 | + </servers> |
| 62 | + |
| 63 | + <mirrors> |
| 64 | + <mirror> |
| 65 | + <id>phylum</id> |
| 66 | + <name>Phylum</name> |
| 67 | + <url>https://maven.phylum.io</url> |
| 68 | + <mirrorOf>central</mirrorOf> |
| 69 | + </mirror> |
| 70 | + </mirrors> |
| 71 | +</settings> |
| 72 | +``` |
| 73 | + |
| 74 | +A blocked package will show up in `mvn` output as missing: |
| 75 | + |
| 76 | +```text |
| 77 | +[INFO] ------------------------------------------------------------------------ |
| 78 | +[INFO] BUILD FAILURE |
| 79 | +[INFO] ------------------------------------------------------------------------ |
| 80 | +[INFO] Total time: 6.871 s |
| 81 | +[INFO] Finished at: 2024-10-29T18:44:40+01:00 |
| 82 | +[INFO] ------------------------------------------------------------------------ |
| 83 | +[ERROR] Failed to execute goal on project demo: Could not collect dependencies for project io.phylum:demo:jar:1.0-SNAPSHOT |
| 84 | +[ERROR] Failed to read artifact descriptor for commons-io:commons-io:jar:2.17.0 |
| 85 | +[ERROR] Caused by: The following artifacts could not be resolved: commons-io:commons-io:pom:2.17.0 (absent): Could not transfer artifact commons-io:commons-io:pom:2.17.0 from/to phylum (https://maven.phylum.io): status code: 424, reason phrase: Failed Dependency (424) |
| 86 | +[ERROR] |
| 87 | +[ERROR] -> [Help 1] |
| 88 | +[ERROR] |
| 89 | +[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. |
| 90 | +[ERROR] Re-run Maven using the -X switch to enable full debug logging. |
| 91 | +[ERROR] |
| 92 | +[ERROR] For more information about the errors and possible solutions, please read the following articles: |
| 93 | +[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException |
| 94 | +``` |
| 95 | + |
| 96 | +If a version range is accepted by the manifest, the package manager will |
| 97 | +automatically attempt to use a version that passes Phylum's policy. |
0 commit comments