Skip to content

SED-4816 Introduce AttachmentStorage#676

Open
cl-exense wants to merge 6 commits into
masterfrom
SED-4816-refactor-attachments-resources
Open

SED-4816 Introduce AttachmentStorage#676
cl-exense wants to merge 6 commits into
masterfrom
SED-4816-refactor-attachments-resources

Conversation

@cl-exense

Copy link
Copy Markdown
Contributor

No description provided.

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request introduces a new AttachmentStorage interface and its implementations (LocalAttachmentStorage and StepStreamingResourceManager) to decouple attachment handling from the general ResourceManager. Various components, including ExportHandler, JUnitXmlReportBuilder, and ReportNodeAttachmentManager, have been refactored to use this new abstraction. The review feedback highlights several critical and high-severity issues, including a path traversal vulnerability in LocalAttachmentStorage due to unsanitized filenames, a potential NullPointerException in PlanRunnerResult when attachmentStorage is null, and fragile directory creation logic. Additionally, improvements are suggested for input validation on attachment IDs, safer type casting of the execution context, pre-compiling regular expressions for performance, and using more portable file path constructors.

Comment thread step-core/src/main/java/step/resources/LocalAttachmentStorage.java Outdated
Comment thread step-core/src/main/java/step/resources/LocalAttachmentStorage.java
Comment thread step-core/src/main/java/step/resources/LocalAttachmentStorage.java
@cl-exense
cl-exense requested a review from david-stephan July 21, 2026 13:52

@david-stephan david-stephan 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.

approved, with minor comment

String className = executionContext == null ? "null" : executionContext.getClass().getName();
return new SkippedAttachmentMeta(filename, mimeType, "UNEXPECTED: Invalid execution context type of class " + className);
}
ExecutionContext context = (ExecutionContext) Objects.requireNonNull(executionContext);

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.

don't think requireNonNull is needed here as it should enter the if condition above.

mimeType = sanitizeMimeType(mimeType);
boolean supportsLineAccess = isLineAccessSupported(mimeType);
StreamingResourceMetadata metadata = new StreamingResourceMetadata(filename, mimeType, supportsLineAccess);
String resourceId = registerNewResource(metadata, uploadContextId);

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.

not related to this PR and should definitely not be refactored as part of it, but we should have avoided to use the word "resource" in the context of streaming as it's quite confusing with the legacy Step "resources"

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.

2 participants