You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@metron.apache.org by tiborm <gi...@git.apache.org> on 2018/08/07 15:35:11 UTC
[GitHub] metron pull request #1142: Metron-1712: Input validation
GitHub user tiborm opened a pull request:
https://github.com/apache/metron/pull/1142
Metron-1712: Input validation
## Contributor Comments
This PR contains the input validation for ipSrcAdr, ipSrcPort, ipDestAdr, ipDestPort fiels.
Please find the details in the https://issues.apache.org/jira/browse/METRON-1724 ticket.
There is a followup ticket on this:
Date rage validation https://issues.apache.org/jira/browse/METRON-1724
We'll open a separated PR when it's done.
## Pull Request Checklist
Thank you for submitting a contribution to Apache Metron.
Please refer to our [Development Guidelines](https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=61332235) for the complete guide to follow for contributions.
Please refer also to our [Build Verification Guidelines](https://cwiki.apache.org/confluence/display/METRON/Verifying+Builds?show-miniview) for complete smoke testing guides.
In order to streamline the review of the contribution we ask you follow these guidelines and ask you to double check the following:
### For all changes:
- [ ] Is there a JIRA ticket associated with this PR? If not one needs to be created at [Metron Jira](https://issues.apache.org/jira/browse/METRON/?selectedTab=com.atlassian.jira.jira-projects-plugin:summary-panel).
- [ ] Does your PR title start with METRON-XXXX where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character.
- [ ] Has your PR been rebased against the latest commit within the target branch (typically master)?
### For code changes:
- [ ] Have you included steps to reproduce the behavior or problem that is being changed or addressed?
- [ ] Have you included steps or a guide to how the change may be verified and tested manually?
- [ ] Have you ensured that the full suite of tests and checks have been executed in the root metron folder via:
```
mvn -q clean integration-test install && dev-utilities/build-utils/verify_licenses.sh
```
- [ ] Have you written or updated unit tests and or integration tests to verify your changes?
- [ ] If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under [ASF 2.0](http://www.apache.org/legal/resolved.html#category-a)?
- [ ] Have you verified the basic functionality of the build by building and running locally with Vagrant full-dev environment or the equivalent?
### For documentation related changes:
- [ ] Have you ensured that format looks appropriate for the output in which it is rendered by building and verifying the site-book? If not then run the following commands and the verify changes via `site-book/target/site/index.html`:
```
cd site-book
mvn site
```
#### Note:
Please ensure that once the PR is submitted, you check travis-ci for build issues and submit an update to your PR as soon as possible.
It is also recommended that [travis-ci](https://travis-ci.org) is set up for your personal repository such that your branches are built there before submitting a pull request.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/tiborm/metron METRON-1712-input-validation
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/metron/pull/1142.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #1142
----
commit 872d1b1ee13e358c18956945d71d3667d19fca8a
Author: merrimanr <me...@...>
Date: 2018-04-12T14:57:48Z
Merge branch 'pcap-front' of https://github.com/simonellistonball/metron into pcaprest
Conflicts:
metron-interface/metron-alerts/src/app/app.module.ts
commit b1b6a7dabea1a1d0d132482c8d97af29c0ac2683
Author: merrimanr <me...@...>
Date: 2018-04-13T15:00:15Z
initial commit
Conflicts:
metron-interface/metron-rest/src/main/java/org/apache/metron/rest/MetronRestApplication.java
metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/PcapQueryController.java
metron-interface/metron-rest/src/main/java/org/apache/metron/rest/util/pcapQueryThread.java
commit 55cf2d945a4fcff1e7e2e47a234037ed6f394b2e
Author: merrimanr <me...@...>
Date: 2018-04-18T15:52:56Z
added license headers
commit 70696d047c6ef4b8ce5fcda03588474ff5b2c506
Author: tiborm <ti...@...>
Date: 2018-07-11T14:58:56Z
METRON-1662: adding download button to pcap tab
commit 4a83d46259736d8c721fb9f640b6ad522f91a559
Author: tiborm <ti...@...>
Date: 2018-07-12T07:09:14Z
METRON-1662: removing unused function from the first iteration
commit 9f57724597240a05d1caeec73882a4ed50aadd9a
Author: tiborm <ti...@...>
Date: 2018-07-12T08:36:15Z
METRON-1662: changing download button label from pdml to pcap
commit 49385eeab612d4f02882888f45defe5cca61f0b9
Author: tiborm <ti...@...>
Date: 2018-07-16T15:00:55Z
METRON-1662: cleaning pdml.ts
commit 32caf44f81cf073e60518e7acccd4a30028f0dd2
Author: tiborm <ti...@...>
Date: 2018-07-16T15:01:47Z
METRON-1662: making unit tests running
commit 38f20f40e213f9785ddbff429453eef541881a8a
Author: tiborm <ti...@...>
Date: 2018-07-17T07:26:38Z
METRON-1662 Cleaning packet component
commit 7983d1e50c5016e904d65c722b3cd081f89e4d26
Author: tiborm <ti...@...>
Date: 2018-07-17T07:27:27Z
METRON-1662 Aligning pcap service and panel to the current status api
commit 28fca20eae9e72c5e4b398dfada3dc920916824a
Author: tiborm <ti...@...>
Date: 2018-07-17T09:06:06Z
METRON-1662 Moving download button below the gird
commit 1d58cc9f112c3c11607e4bdcb755bfa38d4c201f
Author: tiborm <ti...@...>
Date: 2018-07-17T09:06:35Z
METRON-1662 Making progress bar code cleaner
commit e062a63c686854a0301b6e252f14e4ddcdbaf53d
Author: tiborm <ti...@...>
Date: 2018-07-17T09:36:34Z
METRON-1662 Cleaning pcap.service
commit 7a87a0ae9778538e479a1626abde1ecaf81daa2e
Author: tiborm <ti...@...>
Date: 2018-07-17T09:38:32Z
METRON-1662: adding process percentage to PcapStatusResponse
commit 68d9f7aeb7618f76d648165f52b2f9b43946eb5d
Author: tiborm <ti...@...>
Date: 2018-07-17T09:43:37Z
METRON-1662 Aligning download url to the API, adding selectedPage field
commit 3847cb4d0750d789bd3adace746656a7f9a60231
Author: tiborm <ti...@...>
Date: 2018-07-17T16:07:45Z
Adding date range selector to the filter bar
commit c25fd634fa690e02389056d2831518a7e05dccd8
Author: tiborm <ti...@...>
Date: 2018-07-16T15:01:47Z
METRON-1662: making unit tests running
commit b5fe431e14dbffc65ac421162f478776969438ae
Author: tiborm <ti...@...>
Date: 2018-07-18T09:43:30Z
removing validator, adding default value for date fields
commit f0111804e506abc287b99d1b9fedce3c0a82cec6
Author: tiborm <ti...@...>
Date: 2018-07-18T09:48:25Z
adding missing dependency to test
commit 3b645698a42efce819049a41e259ccfde9d1bba0
Author: tiborm <ti...@...>
Date: 2018-07-19T14:33:56Z
aligning pcap request to the current state of the REST API
commit ff294179ae367eec7766d8df4f2bd6d6ede0f16d
Author: tiborm <ti...@...>
Date: 2018-07-19T14:34:26Z
covering pcap filter functionality with unit tests
commit 7326344863201a49d50decfd35a66d1e91dd9c04
Author: tiborm <ti...@...>
Date: 2018-07-19T14:37:47Z
fixing TypeScript compilation error
commit 5720f87ae73385783d9c64a689404516ecbd8a8e
Author: tiborm <ti...@...>
Date: 2018-07-19T14:41:23Z
fixing broken protocol field
commit 4fb13bfbc9e7bbcf3198aff56a511fc7d184e7f7
Author: tiborm <ti...@...>
Date: 2018-07-19T14:58:19Z
Merge branch 'feature/METRON-1554-pcap-query-panel' into METRON-1662
commit 1624cc01e94d65687b028fc45eab7565742fc8ee
Author: tiborm <ti...@...>
Date: 2018-07-19T14:59:28Z
Merge branch 'METRON-1662' into METRON-1676
commit a359b6b5947e8098bcfbfae87f400521b17c81e6
Author: tiborm <ti...@...>
Date: 2018-07-19T15:57:08Z
aligning api to the current available version of the REST API
commit 96a5360491664263e26c84868080a31b4e84d636
Author: Shane Ardell <sa...@...>
Date: 2018-07-17T15:00:15Z
git merge initial pcap work
Conflicts:
src/app/pcap/model/pcap.request.ts
src/app/pcap/pcap-panel/pcap-panel.component.ts
src/app/pcap/pcap.module.ts
src/app/pcap/service/pcap.service.spec.ts
src/app/pcap/service/pcap.service.ts
commit 0a8e57f26bc9f26cde864ef676698d73785ee155
Author: Shane Ardell <sa...@...>
Date: 2018-07-19T15:09:28Z
change function to more descriptive name
commit 05fef858b0331f11b52895e71050da1ddc82205b
Author: Shane Ardell <sa...@...>
Date: 2018-07-19T15:10:09Z
add unit tests for pcap pagination component
commit 7d5db6f6c3245cc6f4a544104c2322c1566b5629
Author: Shane Ardell <sa...@...>
Date: 2018-07-19T17:01:41Z
fix merge issue in pcap service
----
---
[GitHub] metron issue #1142: METRON-1712: PCAP UI Input validation
Posted by merrimanr <gi...@git.apache.org>.
Github user merrimanr commented on the issue:
https://github.com/apache/metron/pull/1142
This has been merged. Can you close @tiborm?
---
[GitHub] metron pull request #1142: METRON-1712: PCAP UI Input validation
Posted by tiborm <gi...@git.apache.org>.
Github user tiborm closed the pull request at:
https://github.com/apache/metron/pull/1142
---
[GitHub] metron issue #1142: METRON-1712: PCAP UI Input validation
Posted by tiborm <gi...@git.apache.org>.
Github user tiborm commented on the issue:
https://github.com/apache/metron/pull/1142
Thanks for the review!
---
[GitHub] metron pull request #1142: METRON-1712: PCAP UI Input validation
Posted by tiborm <gi...@git.apache.org>.
Github user tiborm commented on a diff in the pull request:
https://github.com/apache/metron/pull/1142#discussion_r208695454
--- Diff: metron-interface/metron-alerts/src/app/pcap/pcap-filters/pcap-filters.component.spec.ts ---
@@ -331,13 +337,60 @@ describe('PcapFiltersComponent', () => {
validValues.forEach((value) => {
const els = getFieldWithSubmit('ip-dest-port');
+ expect(isFieldInvalid(els.field)).toBe(false, 'the field should be valid without ' + value);
+ expect(isSubmitDisabled(els.submit)).toBe(false, 'the submit button should be enabled without ' + value);
+
+ setFieldValue(els.field, value);
+
expect(isFieldInvalid(els.field)).toBe(false, 'the field should be valid with ' + value);
expect(isSubmitDisabled(els.submit)).toBe(false, 'the submit button should be enabled with ' + value);
+ tearDown(els.field);
+ });
+ });
+
+
+ it('should disable the form if the ip source field is invalid', () => {
+ const invalidValues = [
+ 'tst',
+ 0o0,
+ 0,
+ '111.111.111',
+ '222.222.222.222.222',
+ '333.333.333.333',
+ ];
+
+ invalidValues.forEach((value) => {
+ const els = getFieldWithSubmit('ip-src-addr');
+ expect(isFieldInvalid(els.field)).toBe(false, 'the field should be valid without ' + value);
+ expect(isSubmitDisabled(els.submit)).toBe(false, 'the submit button should be enabled without ' + value);
+
setFieldValue(els.field, value);
- expect(isFieldInvalid(els.field)).toBe(false, 'the field should be valid with ' + value);
+
+ expect(isFieldInvalid(els.field)).toBe(true, 'the field should be invalid with ' + value);
+ expect(isSubmitDisabled(els.submit)).toBe(true, 'the submit button should be disabled with ' + value);
+ tearDown(els.field);
+ });
+ });
+
+ it('should keep the form enabled if the ip source field is valid', () => {
+ const invalidValues = [
--- End diff --
Fixed. Thanks!
---
[GitHub] metron issue #1142: METRON-1712: PCAP UI Input validation
Posted by justinleet <gi...@git.apache.org>.
Github user justinleet commented on the issue:
https://github.com/apache/metron/pull/1142
+1 pending Travis, thanks for the fixes, this is a great quality of life improvement!
---
[GitHub] metron issue #1142: Metron-1712: Input validation
Posted by justinleet <gi...@git.apache.org>.
Github user justinleet commented on the issue:
https://github.com/apache/metron/pull/1142
Can you please change the title of this PR to "Metron-1712: PCAP UI - Input validation"?
---
[GitHub] metron issue #1142: METRON-1712: PCAP UI Input validation
Posted by tiborm <gi...@git.apache.org>.
Github user tiborm commented on the issue:
https://github.com/apache/metron/pull/1142
Thanks, Justin! I replaced the regexp for IP validation and added new tests to cover that functionality. Nice catch!
I was unable to reproduce the port validation issue you reported. However, I replaced the regexp and double checked the tests. They seem working fine.
---
[GitHub] metron issue #1142: Metron-1712: Input validation
Posted by justinleet <gi...@git.apache.org>.
Github user justinleet commented on the issue:
https://github.com/apache/metron/pull/1142
I ran this up and I'm able to run a query with ip:
- 999.999.999.999
Each of the four octets should be in the range [0-255], e.g. 0.0.0.0, 255.255.255.255, 255.0.12.100 etc.
I'm also able to run with ports:
- 9000
- 90000
- 900000.9989
Ports can be specified with scientific notation (and apparently send properly!)
- 1e3
Ports with pieces of scientific notation and fairly unreasonable values run with empty strings:
- 1e9
- 1+9
- 1.0e-5
---
[GitHub] metron issue #1142: METRON-1712: PCAP UI Input validation
Posted by tiborm <gi...@git.apache.org>.
Github user tiborm commented on the issue:
https://github.com/apache/metron/pull/1142
You're right. Copy paste issue. Fixed. Thanks!
---
[GitHub] metron pull request #1142: METRON-1712: PCAP UI Input validation
Posted by justinleet <gi...@git.apache.org>.
Github user justinleet commented on a diff in the pull request:
https://github.com/apache/metron/pull/1142#discussion_r208575081
--- Diff: metron-interface/metron-alerts/src/app/pcap/pcap-filters/pcap-filters.component.spec.ts ---
@@ -331,13 +337,60 @@ describe('PcapFiltersComponent', () => {
validValues.forEach((value) => {
const els = getFieldWithSubmit('ip-dest-port');
+ expect(isFieldInvalid(els.field)).toBe(false, 'the field should be valid without ' + value);
+ expect(isSubmitDisabled(els.submit)).toBe(false, 'the submit button should be enabled without ' + value);
+
+ setFieldValue(els.field, value);
+
expect(isFieldInvalid(els.field)).toBe(false, 'the field should be valid with ' + value);
expect(isSubmitDisabled(els.submit)).toBe(false, 'the submit button should be enabled with ' + value);
+ tearDown(els.field);
+ });
+ });
+
+
+ it('should disable the form if the ip source field is invalid', () => {
+ const invalidValues = [
+ 'tst',
+ 0o0,
+ 0,
+ '111.111.111',
+ '222.222.222.222.222',
+ '333.333.333.333',
+ ];
+
+ invalidValues.forEach((value) => {
+ const els = getFieldWithSubmit('ip-src-addr');
+ expect(isFieldInvalid(els.field)).toBe(false, 'the field should be valid without ' + value);
+ expect(isSubmitDisabled(els.submit)).toBe(false, 'the submit button should be enabled without ' + value);
+
setFieldValue(els.field, value);
- expect(isFieldInvalid(els.field)).toBe(false, 'the field should be valid with ' + value);
+
+ expect(isFieldInvalid(els.field)).toBe(true, 'the field should be invalid with ' + value);
+ expect(isSubmitDisabled(els.submit)).toBe(true, 'the submit button should be disabled with ' + value);
+ tearDown(els.field);
+ });
+ });
+
+ it('should keep the form enabled if the ip source field is valid', () => {
+ const invalidValues = [
--- End diff --
Looks like this variable is misnamed, can you rename this (and it's usage in at 382)to `validValues`?
---
[GitHub] metron issue #1142: METRON-1712: PCAP UI Input validation
Posted by justinleet <gi...@git.apache.org>.
Github user justinleet commented on the issue:
https://github.com/apache/metron/pull/1142
Hmm, the port errors seem to have been a browser caching issue on the page. I looked at again and it validate ports properly. Sorry for the false alarm.
---