[LM-324] Added Maven support to MDM package-firewall generators#3
Open
Mahesh-Kete wants to merge 1 commit into
Open
[LM-324] Added Maven support to MDM package-firewall generators#3Mahesh-Kete wants to merge 1 commit into
Mahesh-Kete wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add Maven support to MDM package-firewall generators (LM-324)
Jira: LM-324 — Maven support in MDM scripts
Summary
Adds Java / Maven coverage to the Package Firewall MDM script generators (bash + PowerShell). Generated scripts now configure Maven's user settings (
~/.m2/settings.xml) to route all repository requests through the Endor Package Firewall, alongside the existing JavaScript, Python, and Go ecosystems.Maven required special handling: every other config file is line-oriented and uses
#-comment sentinels appended at EOF, butsettings.xmlis XML — the managed block must live inside<settings>…</settings>, and comments are<!-- … -->. So Maven gets its own XML-aware upsert/remove helpers; everything else follows the existing pattern.No new credentials are introduced. Maven natively expands
${env.*}, and the requiredENDOR_API_KEY_ID/ENDOR_API_SECRETare already provided by the existing credential layer (env.shon macOS/Linux,HKCU:\Environmenton Windows). The only new generation-time value is the Maven firewall URL.What's included
Shared
shared/blocks/mavensettings.txt— the managedsettings.xmlfragment (<mirror mirrorOf="*">+ matching<server>), read by both platforms.bash
lib/common.sh— newupsert_xml_block/remove_xml_blockhelpers + XML sentinel markers.templates/maven.sh— orchestration (writes~/.m2/settings.xml).generate.sh—{{MAVEN_REGISTRY_URL}}substitution,MAVEN_BLOCKemission,endor-maven.shbuild + fold intoendor-all.sh, summary output.templates/remove.sh— Maven offboarding.PowerShell (mirror of the bash changes)
lib/common.ps1—Invoke-UpsertXmlBlock/Remove-XmlBlock+ XML markers.templates/maven.ps1,generate.ps1wiring,templates/remove.ps1removal.Docs
package-firewall/README.md,bash/README.md,powershell/README.md(ecosystem tables, block list, per-script behaviour, placeholders, security/removal notes).Behaviour
settings.xmlwrapping the Endor fragment.</settings>; all other elements (e.g. an admin<profile>) are preserved.--dry-run/-DryRunsupported, consistent with the other scripts.Notable fix beyond the spec
The original design used
awk -v frag="$multiline"to insert the fragment, which fails on macOS/BSD awk ("newline in string") on the idempotent re-run — it only works on GNU awk. Since these scripts target Macs via Kandji/Jamf, Case 3 now passes the fragment via a temp file read withgetline, which is portable across BSD and GNU awk.Testing
/usr/bin/awk: fresh-create, idempotency (one mirror after two runs), insert-before-</settings>preserving an existing<profile>, removal preserving other content, and dry-run writing nothing.xmllintconfirms valid XML throughout.bash -n. Generation bakes in{{MAVEN_REGISTRY_URL}}while keeping${env.*}literal.Verification status
/firewall/maven/(base hostfactory.endorlabs.com), per the JFrog Artifactory docs. Matches the code; no change needed./usr/bin/awk(macOS): fresh-create, idempotency,insert-before-
</settings>preserving an existing<profile>, removal, and dry-run — allpass,
xmllint-valid throughout.generate output, fresh-create, idempotency (one mirror after two runs), insert preserving a
profile, removal, Endor-only-file deletion, and dry-run — all pass,
xmllint-valid.Get-ConsoleUserviaexplorer.exe,Set-FileRestrictedAclACLs) still need a real Windows machine — these platform calls can't be exercised by
pwshonmacOS. The Maven XML logic itself is fully validated.
Out of scope / follow-ups
~/.m2/settings.xmlfor resolution.