Skip to content

MLE-34739 Set .gdbinit to mode 0740 and reuse built images only when IDs match - #504

Merged
vitalykorolev merged 1 commit into
developfrom
MLE-34739_gdbinit-structure-test
Nov 24, 2026
Merged

vitalykorolev merged 1 commit into
developfrom
MLE-34739_gdbinit-structure-test

Conversation

@vitalykorolev

Copy link
Copy Markdown
Collaborator

Description

Fixes OpenSCAP finding CCE-83637-9 (CIS file_permission_user_init_files) on rootless images. An explicit chmod 644 on /home/marklogic_user/.gdbinit ran after the CIS hardening step. The file is now 0740, matching other home-directory files such as .bashrc.

Adds test/structure-test-rootless.yaml, which make structure-test loads only for rootless image types. It asserts the mode, uid, and gid of .gdbinit.

Jenkins image reuse: stages reused any local image with the same tag. Build #2 of this branch tested a develop image left on the agent. Build-Image now records the server and platform image IDs. Stages reuse a local tag only when its ID matches, otherwise they unstash and load the archive. Publish keeps its exact-tag checks.

Validation (Jenkins, commit 16cf9e4):

  • Builds Update Jenkinsfile #17 to feature/cld-385-2 #21: SUCCESS.
  • Build feature/cld-385-2 #21: structure 7/7 passed; Docker-Run-Tests 34 passed, 0 failed, 3 skipped. Docker-Run-Tests reused the image loaded by Structure-Tests on the same agent.
  • Build Update Jenkinsfile #16 failed on a GitHub API rate limit during branch indexing (infrastructure).
  • Local: make -n structure-test adds the rootless config only for rootless types. The rootless check fails on the published pre-fix image (-rw-r--r--) and passes on a fixed image.

Not exercised by these builds: SCAP-Scan, the ARM Load-Image path, and Publish-Image. The upgrade image is still always loaded because its tag is mutable.

Checklist:

  • Owner:
  • JIRA_ID as part of branch/PR name

  • Rebase the branch with upstream

  • Squashed all commits into a single commit

  • Added Tests

  • Reviewer:
  • Reviewed Tests

  • Added to Release Wiki/Jira

Copilot AI balanced review requested due to automatic review settings November 21, 2026 16:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

A critical race in Jenkinsfile can record another build’s image IDs after archiving, causing tests or publishing to use the wrong images; capture IDs from the archive or use build-unique tags.

1 open issue
What changed in this PR

This PR hardens rootless MarkLogic images and updates Jenkins to check recorded image IDs before reusing locally tagged images.

Changes:

  • Set .gdbinit permissions to 0740 to address the OpenSCAP finding.
  • Add rootless-only structure tests for .gdbinit permissions and ownership.
  • Record server and platform image IDs and centralize Jenkins image reuse and archive loading.
File Description
test/​structure-test-rootless.yaml Adds .gdbinit mode, UID, and GID checks.
Makefile Includes the additional checks only for rootless image types.
Jenkinsfile Records built image IDs and checks them before reusing local images.
dockerFiles/​marklogic-server-ubi-rootless:base Changes .gdbinit permissions from 0644 to 0740.
.github/​copilot-instructions.md Documents home-file permissions and rootless test configuration.

Review effort: Balanced

Comment thread Jenkinsfile Resolved
…IDs match

The rootless Dockerfile ran chmod 644 on /home/marklogic_user/.gdbinit after the CIS hardening step. That left the others-read bit, which the CIS rule file_permission_user_init_files (0740 or less permissive, CCE-83637-9) rejects. Set the file to 0740 to match other home-directory files such as .bashrc.

Add test/structure-test-rootless.yaml, which make structure-test loads only for rootless image types, to assert the mode, uid, and gid of .gdbinit. Root images do not ship this file, so the check stays out of the shared config.

Build-Image records the server and platform image IDs in built-image-ids.txt and stashes it separately from the archive. The IDs are read before and after the archive is written, and the build fails if a tag moved in between, so the recorded IDs always describe the archived images. SCAP-Scan, Load-Image (ARM), Structure-Tests, Docker-Run-Tests, and Publish-Image call ensureBuiltImagesLoaded(), which reuses a local tag only when its image ID matches the recorded one. Otherwise it unstashes and loads the archive, which replaces the stale tag. Previously these stages loaded the archive only when no image existed under the same tag, so an image left by an earlier build could be tested or published instead.

This showed up in build #2 of this branch, where Structure-Tests ran on cld-docker5 and tested a develop image. Each cld-docker agent has one executor, so the stale image came from an earlier sequential build, not a concurrent one.
@vitalykorolev
vitalykorolev merged commit 246d903 into develop Nov 24, 2026
3 of 5 checks passed
@vitalykorolev
vitalykorolev deleted the MLE-34739_gdbinit-structure-test branch November 24, 2026 07:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants