Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
0dbfbc8
[DEBUG] Part 1 of 2 (- WIP #264 -)
reactive-firewall Apr 3, 2025
593bf91
[FEATURE] Part 2 of 2 implementing initial prototype buffer ENV valid…
reactive-firewall Apr 4, 2025
4765e03
[PATCH] Applied changed found in review (- WIP PR #348 -)
reactive-firewall Apr 4, 2025
d29014e
[PATCH] Apply suggestions from code review (- WIP PR #348 -)
reactive-firewall Apr 4, 2025
51ff443
[PATCH] Applied changes from review (- WIP PR #348 -)
reactive-firewall Apr 5, 2025
13fbb31
[STYLE] Remind app.deepsource.io that module access is normal in python.
reactive-firewall Apr 5, 2025
3e08296
[PATCH] Applied changes as discussed in review (- WIP #348 -)
reactive-firewall Apr 5, 2025
a5b4548
[STYLE] Oops, more corrections found in review (- WIP PR #348 -)
reactive-firewall Apr 5, 2025
69d09f5
[SECURITY] Hardening for test context (- WIP #249 -)
reactive-firewall Apr 5, 2025
5885d93
[SECURITY] More hardening for test context (- WIP PR #349 -)
reactive-firewall Apr 5, 2025
034d846
[TESTING] Improved testing of HEAR handler slightly (- WIP #241 -)
reactive-firewall Apr 7, 2025
393c0af
[MERGE]
reactive-firewall Apr 7, 2025
9219f69
[UPDATE] Version Bump
reactive-firewall Apr 7, 2025
51f6a0b
[UPDATE] (deps): Bump github/codeql-action in /.github/workflows
dependabot[bot] Apr 8, 2025
60e9571
[UPDATE] (deps): Bump ossf/scorecard-action in /.github/workflows
dependabot[bot] Apr 8, 2025
73bacf8
[FEATURE] Initial implementation of module logging for debugging (- W…
reactive-firewall Apr 9, 2025
f068db2
[FEATURE] More implementation of logging style output and related wor…
reactive-firewall Apr 9, 2025
a9777fe
[STYLE] Refactored to avoid PYL-C0201 (- WIP #233 -)
reactive-firewall Apr 9, 2025
f2878d0
[STYLE] Refactored to use lazy formatting to avoid PYL-W1203
reactive-firewall Apr 9, 2025
e333f56
[STYLE] More work related to refactoring to use lazy formatting to av…
reactive-firewall Apr 9, 2025
56468ce
[DOCUMENTATION] Added initial docstring and corrected method def as f…
reactive-firewall Apr 9, 2025
979d5fb
[DOCUMENTATION] Applied improvements found in review (- WIP PR #354 -)
reactive-firewall Apr 10, 2025
fd193f5
[HOTFIX] Fix for regression found in review (- WIP PR #354 -)
reactive-firewall Apr 10, 2025
b3a633a
[PATCH] Apply suggestions from code review (- WIP #354 -)
reactive-firewall Apr 12, 2025
9e75b77
[PATCH] Apply fixes as found in review (- WIP PR #354 -)
reactive-firewall Apr 12, 2025
475dda4
### ChangeLog:
coderabbitai[bot] Apr 12, 2025
b2840c2
[TESTING] Fixing up the implementation for new extra tests (- WIP PR …
reactive-firewall Apr 12, 2025
498ebba
[MERGE] pull request #359 from reactive-firewall/coderabbitai/chat/fd…
reactive-firewall Apr 12, 2025
8d59455
[MERGE]
reactive-firewall Apr 12, 2025
e906154
[PATCH] Apply changes as found in review (- WIP PR #351 -)
reactive-firewall Apr 14, 2025
dd72004
[PATCH] Apply suggestions from code review (- WIP PR #351 -)
reactive-firewall Apr 14, 2025
c320b80
[DEBUG] rerere fix, multicast/__init__.py as found in review (- WIP #…
reactive-firewall Apr 14, 2025
a2a61f4
[PATCH] Apply finishing touches as found in review (- WIP PR #351 -)
reactive-firewall Apr 14, 2025
2955ccc
[VERSION] Release candidate for 2.0 series
reactive-firewall Apr 14, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .ast-grep/rules/python-rule-add-trailing-comma.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# .ast-grep/python-rule-add-trailing-comma.yml
id: python-rule-add-trailing-comma
rule:
all:
- matches: python-rule-argument-last-without-comma
- not:
pattern:
$LAST_ARG,
language: python
message: "Consider adding a trailing comma."
description: Rule for improving future maintainability by pre-emptivly adding trailing commas.
severity: hint
fix:
$LAST_ARG,
examples:
- name: Argument list with missing trailing comma
code: |
# trivial example should match
warnings.warn(
"This should match. because there is no trailing comma.",
stacklevel=2
)
- name: Resulting argument list with trailing comma
code: |
# trivial example should no-longer match
warnings.warn(
"This should match. because there is no trailing comma.",
stacklevel=2,
)
30 changes: 30 additions & 0 deletions .ast-grep/utils/python/structure/argument-last-without-comma.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# .ast-grep/utils/python/structure/argument-last-without-comma.yml
# Argument Structure utils
id: python-rule-argument-last-without-comma
rule:
any:
- kind: identifier
- kind: integer
- kind: float
- kind: string
- kind: keyword_argument
matches: python-rule-keyword-argument-inside-list-with-comma
nthChild:
position: 1
reverse: true
inside:
all:
- kind: argument_list
matches: python-rule-argument-list-with-comma
precedes:
pattern: )
pattern:
$LAST_ARG
all:
- not:
pattern:
$LAST_ARG,
- not:
pattern:
$$$, $LAST_ARG)
language: python
13 changes: 13 additions & 0 deletions .ast-grep/utils/python/structure/argument-list-with-comma.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# .ast-grep/utils/python/structure/argument-list-with-comma.yml
# Argument Structure utils
id: python-rule-argument-list-with-comma
rule:
kind: argument_list
pattern: |
$_FULL_ARG_LIST
has:
all:
- regex: "[,]"
- regex: "\
"
language: python
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# .ast-grep/utils/python/structure/keyword-argument-inside-list-with-comma.yml
# Argument Structure utils
id: python-rule-keyword-argument-inside-list-with-comma
rule:
kind: keyword_argument
inside:
all:
- kind: argument_list
matches: python-rule-argument-list-with-comma
- regex: |
[^(]*[^,]
nthChild:
position: 1
reverse: true
pattern:
$_KW_ARG
language: python
2 changes: 2 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ exclude_lines =
if __name__ in u"__main__":
if __name__ .. .__main__.:
if __sys_path__ not in sys.path:
if __debug__
os.abort()
exit

Expand All @@ -52,6 +53,7 @@ partial_branches =
if __name__ in u'__main__':
if __name__ in u"__main__":
if __name__ in '__main__':
if __debug__
if __sys_path__ not in sys.path:
# don't complain about sys.modules
sys.modules
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@1b549b9259bda1cb5ddde3b41741a82a2d15a841 # v3.28.13
uses: github/codeql-action/init@45775bd8235c68ba998cffa5171334d58593da47 # v3.28.15
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -55,7 +55,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@1b549b9259bda1cb5ddde3b41741a82a2d15a841 # v3.28.13
uses: github/codeql-action/autobuild@45775bd8235c68ba998cffa5171334d58593da47 # v3.28.15

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
Expand All @@ -69,4 +69,4 @@ jobs:
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@1b549b9259bda1cb5ddde3b41741a82a2d15a841 # v3.28.13
uses: github/codeql-action/analyze@45775bd8235c68ba998cffa5171334d58593da47 # v3.28.15
4 changes: 2 additions & 2 deletions .github/workflows/scorecard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
with:
persist-credentials: false
- name: "Run analysis"
uses: ossf/scorecard-action@15bc21f12b2fbbb36fa93d5f2e786f6b18ffe048 # v2.4.1
uses: ossf/scorecard-action@405dced65a1dcc6bc335115002f0690b1f1e49bb # v2.4.1
with:
results_file: results.sarif
results_format: sarif
Expand All @@ -53,6 +53,6 @@ jobs:
retention-days: 5
# Upload the results to GitHub's code scanning dashboard.
- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@1b549b9259bda1cb5ddde3b41741a82a2d15a841 # v3.28.13
uses: github/codeql-action/upload-sarif@45775bd8235c68ba998cffa5171334d58593da47 # v3.28.15
with:
sarif_file: results.sarif
26 changes: 21 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env make -f

# Multicast Python Module
Expand Down Expand Up @@ -212,9 +212,17 @@
$(QUIET)$(RMDIR) ./dist/ 2>$(ERROR_LOG_PATH) || :
$(QUIET)$(RMDIR) ./.eggs/ 2>$(ERROR_LOG_PATH) || :

purge: legacy-purge
purge-test-reports::
$(QUIET)$(RM) ./test-reports/*.xml 2>$(ERROR_LOG_PATH) || :
$(QUIET)$(RMDIR) ./test-reports/ 2>$(ERROR_LOG_PATH) || :

purge-coverage-artifacts: legacy-purge
$(QUIET)$(RM) ./coverage_* 2>$(ERROR_LOG_PATH) || :
$(QUIET)$(RM) ./.coverage.* 2>$(ERROR_LOG_PATH) || :
$(QUIET)$(RM) ./coverage_doctests.xml 2>$(ERROR_LOG_PATH) || :

purge: purge-coverage-artifacts purge-test-reports
$(QUIET)$(WAIT)
$(QUIET)$(ECHO) "$@: Done."

test: just-test
Expand All @@ -223,6 +231,12 @@
$(QUIET)$(COVERAGE) report -m --include=* 2>$(ERROR_LOG_PATH) || : ;
$(QUIET)$(ECHO) "$@: Done."

test-mod: test-mat
$(QUIET)$(DO_FAIL) ;
$(QUIET)$(COVERAGE) combine 2>$(ERROR_LOG_PATH) || : ;
$(QUIET)$(COVERAGE) report -m --include=* 2>$(ERROR_LOG_PATH) || : ;
$(QUIET)$(ECHO) "$@: Done."

test-tox: build
$(QUIET)tox -v -- || tail -n 500 .tox/py*/log/py*.log 2>$(ERROR_LOG_PATH)
$(QUIET)$(COVERAGE) combine 2>$(ERROR_LOG_PATH) || : ;
Expand Down Expand Up @@ -253,18 +267,20 @@
$(QUIET)$(WAIT) ;
$(QUIET)$(DO_FAIL) ;

test-mat: test-mat-build test-mat-bootstrap test-mat-basic test-mat-say test-mat-hear test-mat-usage test-mat-doctests ## Run all minimum acceptance tests
test-mat: cleanup MANIFEST.in test-mat-build test-mat-bootstrap test-mat-basic test-mat-say test-mat-hear test-mat-usage test-mat-doctests ## Run all minimum acceptance tests
$(QUIET)$(WAIT) ;
$(QUIET)$(DO_FAIL) ;

test-mat-doctests: MANIFEST.in ## Run doctests MAT category (doctests are special)
test-mat-doctests: test-reports MANIFEST.in ## Run doctests MAT category (doctests are special)
$(QUIET)if [ -n "$$TESTS_USE_PYTEST" ]; then \
$(ECHO) "SKIP: The target '$@' is not compatable with pytests;"; \
$(ECHO) "Try 'make test-mat-doctests' instead."; \
else \
$(COVERAGE) run -p --source=multicast -m tests.run_selective --group mat --category doctests || DO_FAIL="exit 2" ; \
$(COVERAGE) combine 2>$(ERROR_LOG_PATH) || : ; \
$(COVERAGE) xml --include=* 2>$(ERROR_LOG_PATH) || : ; \
$(QUIET)$(WAIT) ; \
$(COVERAGE) combine --keep --data-file=coverage_doctests ./.coverage.* 2>$(ERROR_LOG_PATH) || : ; \
$(COVERAGE) report -m --include=* --data-file=coverage_doctests 2>$(ERROR_LOG_PATH) || : ; \
$(COVERAGE) xml -o test-reports/coverage_doctests.xml --include=* --data-file=coverage_doctests 2>$(ERROR_LOG_PATH) || : ; \
fi
$(QUIET)$(WAIT) ;
$(QUIET)$(DO_FAIL) ;
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
# The short X.Y version.
version = "v2.0"
# The full version, including alpha/beta/rc tags.
release = "v2.0.5"
release = "v2.0.6"

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
87 changes: 83 additions & 4 deletions multicast/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import socket
import struct
import abc
import logging

# skipcq
__all__ = [
Expand Down Expand Up @@ -52,6 +53,7 @@
"""EXIT_CODES""",
"""EXCEPTION_EXIT_CODES""",
"""_BLANK""",
"""_MCAST_DEFAULT_BUFFER_SIZE""", # added in version 2.0.6
"""_MCAST_DEFAULT_PORT""",
"""_MCAST_DEFAULT_GROUP""",
"""_MCAST_DEFAULT_TTL""",
Expand Down Expand Up @@ -114,7 +116,7 @@

global __version__ # skipcq: PYL-W0604

__version__ = "2.0.5"
__version__ = "2.0.6"
"""The version of this program.

Minimal Acceptance Testing:
Expand Down Expand Up @@ -156,6 +158,7 @@

Attributes:
__version__ (str): The version of this package.
_MCAST_DEFAULT_BUFFER_SIZE (int): Default buffer size for multicast communication (1316).
_MCAST_DEFAULT_PORT (int): Default port for multicast communication (59259).
_MCAST_DEFAULT_GROUP (str): Default multicast group address ('224.0.0.1').
_MCAST_DEFAULT_TTL (int): Default TTL for multicast packets (1).
Expand Down Expand Up @@ -215,6 +218,57 @@
>>>


"""

global _MCAST_DEFAULT_BUFFER_SIZE # skipcq: PYL-W0604

_MCAST_DEFAULT_BUFFER_SIZE = 1316
"""
Arbitrary buffer size to use by default, though any value below 65507 should work.

Minimal Testing:

First set up test fixtures by importing multicast.

>>> import multicast
>>>

Testcase 0: Multicast should have a default buffer size.
A: Test that the _MCAST_DEFAULT_BUFFER_SIZE attribute is initialized.
B: Test that the _MCAST_DEFAULT_BUFFER_SIZE attribute is an int.

>>> multicast._MCAST_DEFAULT_BUFFER_SIZE is not None
True
>>> type(multicast._MCAST_DEFAULT_BUFFER_SIZE) is type(1)
True
>>>
>>> multicast._MCAST_DEFAULT_BUFFER_SIZE > int(1)
True
>>>

Testcase 1: Multicast should validate buffer size constraints.
A: Test that the _MCAST_DEFAULT_BUFFER_SIZE attribute is initialized.
B: Test that the _MCAST_DEFAULT_BUFFER_SIZE attribute is an int.
C: Test that the _MCAST_DEFAULT_BUFFER_SIZE attribute is RFC-791 & RFC-768 compliant.
D: Test that the _MCAST_DEFAULT_BUFFER_SIZE attribute is a smaller than fragment thresholds
for typical ethernet MTUs by default.

>>> multicast._MCAST_DEFAULT_BUFFER_SIZE is not None
True
>>> type(multicast._MCAST_DEFAULT_BUFFER_SIZE) is type(1)
True
>>>
>>> multicast._MCAST_DEFAULT_BUFFER_SIZE >= int(56)
True
>>>
>>> multicast._MCAST_DEFAULT_BUFFER_SIZE <= int(65527)
True
>>>
>>> multicast._MCAST_DEFAULT_BUFFER_SIZE <= int(1500)
True
>>>


"""

global _MCAST_DEFAULT_PORT # skipcq: PYL-W0604
Expand Down Expand Up @@ -351,6 +405,13 @@

"""

if logging.__name__ is not None: # pragma: no branch
logging.getLogger(__module__).addHandler(logging.NullHandler())
logging.getLogger(__module__).debug(
"Loading %s", # lazy formatting to avoid PYL-W1203
__module__,
)

if sys.__name__ is None:
raise ModuleNotFoundError(
"FAIL: we could not import sys. We're like in the matrix! ABORT."
Expand All @@ -365,7 +426,13 @@
if socket.__name__ is None:
raise ModuleNotFoundError("FAIL: we could not import socket. ABORT.") from None
else: # pragma: no branch
socket.setdefaulttimeout(int(_MCAST_DEFAULT_TTL))
_tmp_mcast_value = int(_MCAST_DEFAULT_TTL)
logging.getLogger(__module__).debug(
"Setting default socket timeout to %d", # lazy formatting to avoid PYL-W1203
_tmp_mcast_value,
)
socket.setdefaulttimeout(_tmp_mcast_value)
del _tmp_mcast_value # skipcq - cleanup any bootstrap/setup leaks early

if struct.__name__ is None:
raise ModuleNotFoundError("FAIL: we could not import struct. ABORT.") from None
Expand Down Expand Up @@ -407,15 +474,23 @@
if _config is None:
raise ImportError("FAIL: we could not import environment. ABORT.") from None
else:
logging.getLogger(__module__).debug("Configuring overrides and defaults.")
_MCAST_DEFAULT_PORT = _config["port"]
_MCAST_DEFAULT_GROUP = _config["group"]
_MCAST_DEFAULT_TTL = _config["ttl"]
_MCAST_DEFAULT_BUFFER_SIZE = _config["buffer_size"]
global _MCAST_DEFAULT_BIND_IP # skipcq: PYL-W0604
_MCAST_DEFAULT_BIND_IP = _config["bind_addr"]
global _MCAST_DEFAULT_GROUPS # skipcq: PYL-W0604
_MCAST_DEFAULT_GROUPS = _config["groups"]
global _MCAST_DEFAULT_BUFFER # skipcq: PYL-W0604
_MCAST_DEFAULT_BUFFER = _config["buffer_size"]
if __debug__: # pragma: no branch
logging.getLogger(__module__).info("Overrides and defaults are configured.")
logging.getLogger(__module__).debug("Defaults:")
for key, value in _config.items():
logging.getLogger(__module__).debug(
"\t%s=%s", # lazy formatting to avoid PYL-W1203
key, value,
)

del _config # skipcq - cleanup any bootstrap/setup leaks early

Expand Down Expand Up @@ -491,6 +566,10 @@ def buildArgs(cls, calling_parser_group):

"""
if calling_parser_group is None: # pragma: no branch
logging.getLogger(__module__).debug(
"Building %s arguments.", # lazy formatting to avoid PYL-W1203
__name__,
)
calling_parser_group = argparse.ArgumentParser(
prog=str(cls.__name__ if cls.__proc__ is None else cls.__proc__),
description=cls.__prologue__,
Expand Down
Loading
Loading