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

Add DICOM (Digital Imaging and Communications in Medicine) protocol support #4891

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

Open
tmart234 wants to merge 21 commits into secdev:master
base: master
Choose a base branch
Loading
from tmart234:master

Conversation

@tmart234
Copy link

@tmart234 tmart234 commented Dec 30, 2025

Summary

DICOM communications is used in medical imaging systems. This PR adds Scapy layers for the DICOM Upper Layer Protocol (DICOM PS3.8).

Features

  • Full PDU support: A-ASSOCIATE-RQ/AC/RJ, P-DATA-TF, A-RELEASE-RQ/RP, A-ABORT
  • Variable item negotiation: Application Context, Presentation Context, User Information, User Identity, Async Operations, Role Selection
  • DIMSE command packets: C-ECHO, C-STORE, C-FIND, C-MOVE, C-GET

Usage

from scapy.contrib.dicom import *
# Build an A-ASSOCIATE-RQ
pkt = DICOM() / A_ASSOCIATE_RQ(
 called_ae_title=_pad_ae_title("SERVER"),
 calling_ae_title=_pad_ae_title("CLIENT"),
 variable_items=[
 DICOMVariableItem() / DICOMApplicationContext(),
 build_presentation_context_rq(1, VERIFICATION_SOP_CLASS_UID, [DEFAULT_TRANSFER_SYNTAX_UID]),
 build_user_information(max_pdu_length=16384),
 ]
)
# Build a C-MOVE-RQ
move_rq = C_MOVE_RQ(message_id=1, move_destination=b"DEST_AE")

Testing

  • 59 unit tests in test/contrib/dicom.uts
  • All tests pass on Python 3.9+

References

Copy link

codecov bot commented Dec 30, 2025
edited
Loading

Codecov Report

❌ Patch coverage is 52.34708% with 335 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.62%. Comparing base (f303033) to head (f8d6ec4).

Files with missing lines Patch % Lines
scapy/contrib/dicom.py 52.34% 335 Missing ⚠️
Additional details and impacted files
@@ Coverage Diff @@
## master #4891 +/- ##
==========================================
- Coverage 80.84% 80.62% -0.22% 
==========================================
 Files 369 370 +1 
 Lines 90968 91671 +703 
==========================================
+ Hits 73544 73913 +369 
- Misses 17424 17758 +334 
Files with missing lines Coverage Δ
scapy/contrib/dicom.py 52.34% <52.34%> (ø)

... and 6 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link

Thanks for the PR. I’ve stared the unit tests. Looks good, however, could you please add type hints to your layer?

Copy link
Author

Thanks for the PR. I’ve stared the unit tests. Looks good, however, could you please add type hints to your layer?

Added

Copy link
Contributor

Besides the small Flake8 issues, LGTM.

@gpotter2 do you want to have a final look?

Copy link
Author

tmart234 commented Jan 9, 2026

@polybassa fixed the Flake8 issues

Copy link
Member

I trust you @polybassa !

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 adds comprehensive support for the DICOM (Digital Imaging and Communications in Medicine) Upper Layer Protocol to Scapy, enabling network analysis and interaction with medical imaging systems. The implementation follows the DICOM PS3.8 specification and includes extensive packet definitions for protocol negotiation, data transfer, and DIMSE commands.

Changes:

  • Added complete DICOM protocol layer implementation with PDU types, variable items, and DIMSE command packets
  • Implemented a high-level DICOMSocket class for association management and DIMSE operations
  • Added 59 comprehensive unit tests covering packet construction, parsing, and round-trip serialization

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 8 comments.

File Description
scapy/contrib/dicom.py Main implementation file containing DICOM packet classes, field types, PDU definitions, DIMSE commands, and DICOMSocket for application-level operations
test/contrib/dicom.uts Comprehensive test suite with 59 tests covering module loading, PDU construction/parsing, variable items, DIMSE packets, helper functions, and edge cases

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

polybassa and others added 2 commits January 11, 2026 20:05
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Contributor

I trust you @polybassa !

Thanks. I've added the last two copilot finding.

@polybassa polybassa enabled auto-merge (squash) January 11, 2026 19:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@gpotter2 gpotter2 gpotter2 left review comments

Copilot code review Copilot Copilot left review comments

@polybassa polybassa polybassa left review comments

+1 more reviewer

@polydroi polydroi polydroi left review comments

Reviewers whose approvals may not affect merge requirements

At least 1 approving review is required to merge this pull request.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /