Class SecretRegistry
Host machinery, not part of the plugin-facing API. It lives in this package
because both halves need it - Secret implementations register into it, and the host's output
streams mask against it - and neither can see the other's package. A plugin has no reason to touch
it.
Replaces walking a configuration's password descriptors up front to guess which values
might be secret. That could only cover what the host thought to look at - a task's own
properties and one hop of references - so a credential found deeper was never masked. The set is
built the other way round instead: revealing a Secret adds the value it just decrypted, so
anything an extension actually got hold of is masked, at whatever depth it came from.
Shared by reference, not snapshotted
Consumers must hold the registry itself rather than a copy of its contents. An extension typically reveals a secret and only then starts the work that produces output, and may reveal more while output is already streaming, so a snapshot taken when a stream was wired up would miss exactly the secrets that matter. The backing set is concurrent for the same reason: revealing happens on the worker thread while masking happens on whatever thread is pumping output.Ambient during an execution
install(com.xebialabs.xlrelease.osgi.api.tasks.SecretRegistry) publishes a registry for the current thread so that revealing a secret anywhere
beneath it - including inside record binding, which has no other way to reach the execution - is
recorded. When nothing is installed, revealing still decrypts but registers nothing: that is the
case for a connection test or a lookup, which have no task log to mask into.
Deliberately not inheritable. A thread an extension starts does not pick the registry up implicitly, so it cannot mask against another execution's secrets; code that needs to mask from another thread is given the registry object directly, which is what holding it by reference is for.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic SecretRegistryinstall(SecretRegistry registry) Installsregistryfor this thread, returning whatever was installed before so the caller canrestore(com.xebialabs.xlrelease.osgi.api.tasks.SecretRegistry)it in afinally.booleanisEmpty()Whether anything has been revealed - lets a caller skip masking work entirely.linewith every revealed secret replaced by********.voidRecords a revealed plaintext so every later write to the task log has it masked.static voidrestore(SecretRegistry previous) Puts back whatinstall(com.xebialabs.xlrelease.osgi.api.tasks.SecretRegistry)returned, clearing the thread-local when that wasnull.
-
Constructor Details
-
SecretRegistry
public SecretRegistry()
-
-
Method Details
-
register
Records a revealed plaintext so every later write to the task log has it masked. -
mask
linewith every revealed secret replaced by********.Operates on a whole assembled line rather than a raw buffer fragment: a secret split across two writes matches neither half, so callers assemble lines first. Returns the input unchanged when nothing has been revealed, which is the common case.
-
isEmpty
public boolean isEmpty()Whether anything has been revealed - lets a caller skip masking work entirely. -
install
Installsregistryfor this thread, returning whatever was installed before so the caller canrestore(com.xebialabs.xlrelease.osgi.api.tasks.SecretRegistry)it in afinally. -
restore
Puts back whatinstall(com.xebialabs.xlrelease.osgi.api.tasks.SecretRegistry)returned, clearing the thread-local when that wasnull.
-