Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Protect event tags from external mutation#267

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

@tcheeric
Copy link
Owner

Summary

  • Defensively copy tag lists inGenericEvent constructors andsetTags
  • Expose tags through an unmodifiable view
  • Update zap request validation tests to operate on tag copies

Testing

  • mvn -q verify(fails: Coverage checks have not been met for nostr-java-encryption)
  • mvn -q -pl nostr-java-event -am test

https://chatgpt.com/codex/tasks/task_b_6898e475555c833192749c48a74b0281

Copy link
Contributor

CopilotAI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Pull Request Overview

This PR protects theGenericEvent class from external mutation by implementing defensive copying and immutable views of tag collections. The changes prevent external code from directly modifying an event's tags after creation or retrieval.

  • Implements defensive copying in constructors and setter methods to prevent shared mutable state
  • Exposes tags through an unmodifiable view to prevent external modification
  • Updates test cases to work with the new immutable tag access pattern

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

FileDescription
GenericEvent.javaAdds defensive copying in constructor and setTags method, implements unmodifiable tag getter
ZapRequestEventValidateTest.javaUpdates tests to create tag copies before modification since direct tag mutation is no longer possible

}
}

publicList<BaseTag>getTags() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Adding a new public getTags() method could be a breaking change if this method already exists in the class or its parent classes. Verify that this doesn't override an existing method with different behavior.

Suggested change
publicList<BaseTag>getTags() {
publicList<BaseTag>getBaseTags() {

Copilot uses AI. Check for mistakes.
@tcheerictcheeric merged commit0895c09 intodevelopAug 10, 2025
1 check failed
@tcheerictcheeric deleted the codex/update-genericevent-tag-handling-methods branchAugust 10, 2025 20:34
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

Copilot code reviewCopilotCopilot left review comments

Assignees

No one assigned

Labels

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

@tcheeric

[8]ページ先頭

©2009-2025 Movatter.jp