Skip to content

NIFI-12297 Standardize File Path resolution in Persistence Providers#7968

Closed
exceptionfactory wants to merge 1 commit intoapache:mainfrom
exceptionfactory:NIFI-12297
Closed

NIFI-12297 Standardize File Path resolution in Persistence Providers#7968
exceptionfactory wants to merge 1 commit intoapache:mainfrom
exceptionfactory:NIFI-12297

Conversation

@exceptionfactory
Copy link
Contributor

Summary

NIFI-12297 Standardizes file path resolution in the NiFi Registry File System Bundle and Flow Persistence Providers, as well as the file-backed client for system tests. These changes replace string concatenation and related strategies with a standard approach using Java NIO Paths. Using Paths ensures consistent directory separator handling and path normalization.

Additional changes include updating related unit tests to reuse shared identifier values.

Tracking

Please complete the following tracking steps prior to pull request creation.

Issue Tracking

Pull Request Tracking

  • Pull Request title starts with Apache NiFi Jira issue number, such as NIFI-00000
  • Pull Request commit message starts with Apache NiFi Jira issue number, as such NIFI-00000

Pull Request Formatting

  • Pull Request based on current revision of the main branch
  • Pull Request refers to a feature branch with one commit containing changes

Verification

Please indicate the verification steps performed prior to pull request creation.

Build

  • Build completed using mvn clean install -P contrib-check
    • JDK 21

Licensing

  • New dependencies are compatible with the Apache License 2.0 according to the License Policy
  • New dependencies are documented in applicable LICENSE and NOTICE files

Documentation

  • Documentation formatting appears as expected in rendered files

final String snapshotFilename = bucketId + "/" + flowId + "/" + version + "/" + version + SNAPSHOT_EXTENSION;
return new File(flowStorageDir, snapshotFilename);
final String versionExtension = version + SNAPSHOT_EXTENSION;
final Path snapshotLocation = Paths.get(getNormalizedId(bucketId), getNormalizedId(flowId), Integer.toString(version), versionExtension);

Check failure

Code scanning / CodeQL

Uncontrolled data used in path expression

This path depends on a [user-provided value](1). This path depends on a [user-provided value](2).
}

static Path getArtifactPath(final String bucketId, final String groupId, final String artifactId) {
return Paths.get(sanitize(bucketId), sanitize(groupId), sanitize(artifactId)).normalize();

Check failure

Code scanning / CodeQL

Uncontrolled data used in path expression

This path depends on a [user-provided value](1).

private Path getNormalizedIdPath(final String id) {
final String normalizedId = getNormalizedId(id);
return Paths.get(normalizedId).normalize();

Check failure

Code scanning / CodeQL

Uncontrolled data used in path expression

This path depends on a [user-provided value](1). This path depends on a [user-provided value](2). This path depends on a [user-provided value](3). This path depends on a [user-provided value](4). This path depends on a [user-provided value](5).

private Path getNormalizedIdPath(final String id) {
final String normalizedId = id.replaceAll("\\.", "").replaceAll("/", "").trim();
return Paths.get(normalizedId).normalize();

Check failure

Code scanning / CodeQL

Uncontrolled data used in path expression

This path depends on a [user-provided value](1). This path depends on a [user-provided value](2). This path depends on a [user-provided value](3). This path depends on a [user-provided value](4). This path depends on a [user-provided value](5). This path depends on a [user-provided value](6). This path depends on a [user-provided value](7). This path depends on a [user-provided value](8). This path depends on a [user-provided value](9).
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.

1 participant