Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Allow use of valid Port 0 #40259

Merged
merged 8 commits into from
Aug 21, 2024
Merged

Conversation

MarcWort
Copy link
Contributor

Proposed commit message

Port 0 is a normal but reserved port.
See: https://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xhtml or RFC6335 Section 6

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works
  • I have added an entry in CHANGELOG.next.asciidoc or CHANGELOG-developer.next.asciidoc.

Use cases

Our internet facing server with Shorewall sometimes logs packets with SPT=0.
These trigger an alarm because of many dropped messages in our monitoring.

Logs

{"log.level":"debug","@timestamp":"2024-06-24T16:21:53.900+0200","log.logger":"elasticsearch","log.origin":{"function":"github.com/elastic/beats/v7/libbeat/outputs/elasticsearch.(*Client).bulkCollectPublishFails","file.name":"elasticsearch/client.go","file.line":455},"message":"Cannot index event publisher.Event{Content:beat.Event{Timestamp:time.Date(2024, time.June, 24, 14, 21, 53, 112000000, time.UTC), Meta:{\"pipeline\":\"logs-shorewall\",\"truncated\":false}, Fields:{\"agent\":{\"ephemeral_id\":\"6981b9de-7b5c-4058-a9e6-cc33b1ece2c4\",\"id\":\"788b7445-d688-46d8-8c47-e16da00a4f11\",\"name\":\"filebeat\",\"type\":\"filebeat\",\"version\":\"8.13.4\"},\"ecs\":{\"version\":\"8.0.0\"},\"event\":{\"severity\":6},\"host\":{\"name\":\"server123\"},\"input\":{\"type\":\"syslog\"},\"log\":{\"source\":{\"address\":\"192.168.110.104:34265\"}},\"message\":\"Shorewall FORWARD DROP IN=bond1 OUT=bond1 MAC=aa:aa:aa:aa:bb:bb:bb:bb SRC=123.123.123.123 DST=1.2.3.4 LEN=52 TOS=0x00 PREC=0x00 TTL=56 ID=0 DF PROTO=TCP SPT=0 DPT=80 WINDOW=875 RES=0x00 SYN URGP=0 \",\"process\":{\"program\":\"kernel\"},\"syslog\":{\"facility\":0,\"facility_label\":\"kernel\",\"priority\":6,\"severity_label\":\"Informational\"}}, Private:interface {}(nil), TimeSeries:false}, Flags:0x1, Cache:publisher.EventCache{m:mapstr.M(nil)}} (status=400): {\"type\":\"illegal_argument_exception\",\"reason\":\"invalid source port [null]\"}, dropping event!","service.name":"filebeat","ecs.version":"1.6.0"}

@MarcWort MarcWort requested a review from a team as a code owner July 16, 2024 13:54
@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Jul 16, 2024
Copy link

cla-checker-service bot commented Jul 16, 2024

💚 CLA has been signed

Copy link
Contributor

mergify bot commented Jul 16, 2024

This pull request does not have a backport label.
If this is a bug or security fix, could you label this PR @MarcWort? 🙏.
For such, you'll need to label your PR with:

  • The upcoming major version of the Elastic Stack
  • The upcoming minor version of the Elastic Stack (if you're not pushing a breaking change)

To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-v8./d.0 is the label to automatically backport to the 8./d branch. /d is the digit

@pierrehilbert pierrehilbert added the Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team label Jul 16, 2024
@elasticmachine
Copy link
Collaborator

Pinging @elastic/elastic-agent-data-plane (Team:Elastic-Agent-Data-Plane)

@botelastic botelastic bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Jul 16, 2024
@pierrehilbert pierrehilbert requested review from rdner and faec and removed request for AndersonQ and leehinman July 16, 2024 14:59
Copy link
Contributor

mergify bot commented Jul 17, 2024

This pull request is now in conflicts. Could you fix it? 🙏
To fixup this pull request, you can check out it locally. See documentation: https://help.github.com/articles/checking-out-pull-requests-locally/

git fetch upstream
git checkout -b mwn-fix-valid-port-0 upstream/mwn-fix-valid-port-0
git merge upstream/main
git push upstream mwn-fix-valid-port-0

rdner
rdner approved these changes Aug 1, 2024
@rdner rdner enabled auto-merge (squash) August 1, 2024 12:27
@rdner
Copy link
Member

rdner commented Aug 2, 2024

/test

@rdner
Copy link
Member

rdner commented Aug 2, 2024

@MarcWort the test does not pass, could you please fix it?

=== FAIL: libbeat/processors/communityid TestRun/invalid_destination_port (0.00s)
    communityid_test.go:85:
        	Error Trace:	/opt/buildkite-agent/builds/bk-agent-prod-gcp-1722602121494028845/elastic/beats-libbeat/libbeat/processors/communityid/communityid_test.go:189
        	            				/opt/buildkite-agent/builds/bk-agent-prod-gcp-1722602121494028845/elastic/beats-libbeat/libbeat/processors/communityid/communityid_test.go:85
        	Error:      	Not equal:
        	            	expected: <nil>(<nil>)
        	            	actual  : string("1:YaVkVTbWUkgn0a2QrblLOEsia9g=")
        	Test:       	TestRun/invalid_destination_port
=== FAIL: libbeat/processors/communityid TestRun (0.00s)

auto-merge was automatically disabled August 7, 2024 15:34

Head branch was pushed to by a user without write access

@MarcWort
Copy link
Contributor Author

MarcWort commented Aug 7, 2024

@rdner Of course, and sorry for the late reply, I was on vacation.

Copy link
Contributor

mergify bot commented Aug 8, 2024

This pull request is now in conflicts. Could you fix it? 🙏
To fixup this pull request, you can check out it locally. See documentation: https://help.github.com/articles/checking-out-pull-requests-locally/

git fetch upstream
git checkout -b mwn-fix-valid-port-0 upstream/mwn-fix-valid-port-0
git merge upstream/main
git push upstream mwn-fix-valid-port-0

@faec faec enabled auto-merge (squash) August 13, 2024 20:42
@MarcWort
Copy link
Contributor Author

Could someone please run the remaining tests to get this done?

@nimarezainia
Copy link
Contributor

/test

@pierrehilbert
Copy link
Collaborator

run docs-build

@faec faec merged commit 8eb0f42 into elastic:main Aug 21, 2024
123 checks passed
@MarcWort MarcWort deleted the mwn-fix-valid-port-0 branch August 21, 2024 08:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants