You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by "dan-s1 (via GitHub)" <gi...@apache.org> on 2025/11/28 16:37:34 UTC
[PR] NIFI-15272 Improved the validation for BitbucketFlowRegistryClient BITBUCKET_API_URL property by ensuring only a host or url are entered. [nifi]
dan-s1 opened a new pull request, #10579:
URL: https://github.com/apache/nifi/pull/10579
<!-- Licensed to the Apache Software Foundation (ASF) under one or more -->
<!-- contributor license agreements. See the NOTICE file distributed with -->
<!-- this work for additional information regarding copyright ownership. -->
<!-- The ASF licenses this file to You under the Apache License, Version 2.0 -->
<!-- (the "License"); you may not use this file except in compliance with -->
<!-- the License. You may obtain a copy of the License at -->
<!-- http://www.apache.org/licenses/LICENSE-2.0 -->
<!-- Unless required by applicable law or agreed to in writing, software -->
<!-- distributed under the License is distributed on an "AS IS" BASIS, -->
<!-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -->
<!-- See the License for the specific language governing permissions and -->
<!-- limitations under the License. -->
# Summary
[NIFI-15272](https://issues.apache.org/jira/browse/NIFI-15272)
# Tracking
Please complete the following tracking steps prior to pull request creation.
### Issue Tracking
- [ ] [Apache NiFi Jira](https://issues.apache.org/jira/browse/NIFI) issue created
### 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 `./mvnw clean install -P contrib-check`
- [ ] JDK 21
- [ ] JDK 25
### Licensing
- [ ] New dependencies are compatible with the [Apache License 2.0](https://apache.org/licenses/LICENSE-2.0) according to the [License Policy](https://www.apache.org/legal/resolved.html)
- [ ] New dependencies are documented in applicable `LICENSE` and `NOTICE` files
### Documentation
- [ ] Documentation formatting appears as expected in rendered files
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] NIFI-15272 Improved the validation for BitbucketFlowRegistryClient BITBUCKET_API_URL property by ensuring only a host or url are entered. [nifi]
Posted by "exceptionfactory (via GitHub)" <gi...@apache.org>.
exceptionfactory commented on code in PR #10579:
URL: https://github.com/apache/nifi/pull/10579#discussion_r2572261503
##########
nifi-extension-bundles/nifi-atlassian-bundle/nifi-atlassian-extensions/src/main/java/org/apache/nifi/atlassian/bitbucket/BitbucketFlowRegistryClient.java:
##########
@@ -46,10 +48,25 @@ public class BitbucketFlowRegistryClient extends AbstractGitFlowRegistryClient {
.required(true)
.build();
+ private static final Pattern HOST_PATTERN = Pattern.compile("(\\[[\\p{XDigit}:.]*[%\\p{Alnum}]*]|[^\\[/?#:]*)");
+ private static final Validator BITBUCKET_API_URL_VALIDATOR = (subject, input, validationContext) -> {
+ if (input == null || input.isBlank()) {
+ return (new ValidationResult.Builder()).subject(subject).explanation(String.format("'%s' cannot be blank", subject)).input(input).build();
+ } else if (HOST_PATTERN.matcher(input).matches()) {
+ return (new ValidationResult.Builder()).subject(subject).input(input).valid(true).build();
+ } else {
+ ValidationResult validationResult = StandardValidators.URL_VALIDATOR.validate(subject, input, validationContext);
+ if (validationResult.isValid()) {
+ return validationResult;
+ } else {
+ return (new ValidationResult.Builder()).subject(subject).explanation(String.format("'%s' is neither a host or URL", subject)).input(input).build();
+ }
+ }
Review Comment:
I recommend refactoring this a bit to create a single `ValidationResult.Builder` and a single `return` statement at the end. That way, repetitive elements like `subject` and `input` could be declared once.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] NIFI-15272 Improved the validation for BitbucketFlowRegistryClient BITBUCKET_API_URL property by ensuring only a host or url are entered. [nifi]
Posted by "exceptionfactory (via GitHub)" <gi...@apache.org>.
exceptionfactory merged PR #10579:
URL: https://github.com/apache/nifi/pull/10579
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] NIFI-15272 Improved the validation for BitbucketFlowRegistryClient BITBUCKET_API_URL property by ensuring only a host or url are entered. [nifi]
Posted by "pvillard31 (via GitHub)" <gi...@apache.org>.
pvillard31 commented on PR #10579:
URL: https://github.com/apache/nifi/pull/10579#issuecomment-3596015044
My bad, I didn't read further the defined pattern... IIUC it looks like the example I gave would still be considered valid. Could be good to update the unit tests with more patterns. So yeah, if I read things correctly, it looks like all the values I used during my development/testing would be valid.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] NIFI-15272 Improved the validation for BitbucketFlowRegistryClient BITBUCKET_API_URL property by ensuring only a host or url are entered. [nifi]
Posted by "pvillard31 (via GitHub)" <gi...@apache.org>.
pvillard31 commented on PR #10579:
URL: https://github.com/apache/nifi/pull/10579#issuecomment-3595996677
I do not believe this is OK. I think that `http://xxx.xxx.xxx.xxx:zzz/` should be considered valid. This is what I used for testing of the Data Center edition as we can see in the screenshots of #10322.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] NIFI-15272 Improved the validation for BitbucketFlowRegistryClient BITBUCKET_API_URL property by ensuring only a host or url are entered. [nifi]
Posted by "exceptionfactory (via GitHub)" <gi...@apache.org>.
exceptionfactory commented on code in PR #10579:
URL: https://github.com/apache/nifi/pull/10579#discussion_r2578438434
##########
nifi-extension-bundles/nifi-atlassian-bundle/nifi-atlassian-extensions/src/main/java/org/apache/nifi/atlassian/bitbucket/BitbucketFlowRegistryClient.java:
##########
@@ -46,10 +48,31 @@ public class BitbucketFlowRegistryClient extends AbstractGitFlowRegistryClient {
.required(true)
.build();
+ private static final Pattern HOST_PATTERN = Pattern.compile("(\\[[\\p{XDigit}:.]*[%\\p{Alnum}]*]|[^\\[/?#:]*)");
+ private static final Validator BITBUCKET_API_URL_VALIDATOR = (subject, input, validationContext) -> {
+ final ValidationResult.Builder builder = new ValidationResult.Builder();
+ builder.subject(subject).input(input);
+
+ if (input == null || input.isBlank()) {
+ builder.explanation(String.format("'%s' cannot be blank", subject)).valid(false);
+ } else if (HOST_PATTERN.matcher(input).matches()) {
+ builder.explanation(String.format("%s is a valid host", subject)).valid(true);
+ } else {
+ final ValidationResult validationResult = StandardValidators.URL_VALIDATOR.validate(subject, input, validationContext);
+ if (validationResult.isValid()) {
+ builder.explanation(String.format("%s is a valid url", subject)).valid(true);
+ } else {
+ builder.explanation(String.format("'%s' is neither a host or URL", subject)).valid(false);
+ }
+ }
Review Comment:
Recommend replacing `String.format()` with `.formatted()` for improved readability.
##########
nifi-extension-bundles/nifi-atlassian-bundle/nifi-atlassian-extensions/src/main/java/org/apache/nifi/atlassian/bitbucket/BitbucketFlowRegistryClient.java:
##########
@@ -46,10 +48,31 @@ public class BitbucketFlowRegistryClient extends AbstractGitFlowRegistryClient {
.required(true)
.build();
+ private static final Pattern HOST_PATTERN = Pattern.compile("(\\[[\\p{XDigit}:.]*[%\\p{Alnum}]*]|[^\\[/?#:]*)");
+ private static final Validator BITBUCKET_API_URL_VALIDATOR = (subject, input, validationContext) -> {
+ final ValidationResult.Builder builder = new ValidationResult.Builder();
+ builder.subject(subject).input(input);
+
+ if (input == null || input.isBlank()) {
+ builder.explanation(String.format("'%s' cannot be blank", subject)).valid(false);
+ } else if (HOST_PATTERN.matcher(input).matches()) {
+ builder.explanation(String.format("%s is a valid host", subject)).valid(true);
+ } else {
+ final ValidationResult validationResult = StandardValidators.URL_VALIDATOR.validate(subject, input, validationContext);
+ if (validationResult.isValid()) {
+ builder.explanation(String.format("%s is a valid url", subject)).valid(true);
Review Comment:
```suggestion
builder.explanation(String.format("%s is a valid URL", subject)).valid(true);
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org