Skip to content

improve DNS contact unit test coverage#3251

Open
uruwhy wants to merge 3 commits intomasterfrom
coverage-dns-contact
Open

improve DNS contact unit test coverage#3251
uruwhy wants to merge 3 commits intomasterfrom
coverage-dns-contact

Conversation

@uruwhy
Copy link
Contributor

@uruwhy uruwhy commented Feb 10, 2026

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

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Ran tests, ran Linux agent with DNS contact to ensure functionality still worked as intended.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works

Copy link
Contributor

Copilot AI 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 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_bytes method
  • 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.

@sonarqubecloud
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments