Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves unit test coverage for the DNS C2 contact and includes bug fixes and code cleanup. It adds comprehensive tests for DNS packet handling, payload downloads, file uploads, and error conditions, while also fixing a base64 decoding bug in existing tests.
Changes:
- Added unit tests for DNS packet parsing and response generation
- Fixed base64 decoding bug in instruction download test (stripping comma delimiter before decoding)
- Added comprehensive tests for payload downloads and file uploads including error scenarios
- Removed unused
_generate_pointer_and_qname_bytesmethod - Improved error logging in payload request handling
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| tests/contacts/test_contact_dns.py | Added new test class TestDnsAuxiliary for DNS packet tests, new fixtures for payload operations, comprehensive tests for payload download/upload error handling, IPv6 placeholder test, and fixed base64 decoding bug in instruction download test |
| app/contacts/contact_dns.py | Removed unused _generate_pointer_and_qname_bytes method, improved __str__ formatting with proper indentation for answers, and added error logging when file fetch fails |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Description
Part 1/n of PRs improving unit test coverage.
Adds more unit tests for the DNS C2 contact and cleans up existing DNS c2 contact code.
Type of change
How Has This Been Tested?
Ran tests, ran Linux agent with DNS contact to ensure functionality still worked as intended.
Checklist: