From f42a57cb0e80de42949810057d36df7c4a6b5146 Mon Sep 17 00:00:00 2001 From: Christian Giese Date: Wed, 24 Jul 2024 21:52:15 +0000 Subject: [PATCH] minor codacy fixes --- .github/workflows/codacy-analysis.yml | 18 ++++++++++-------- .github/workflows/python-publish.yml | 3 ++- pyrad/packet.py | 7 ++++--- pyrad/tools.py | 2 ++ 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/.github/workflows/codacy-analysis.yml b/.github/workflows/codacy-analysis.yml index b307da2..977c81e 100644 --- a/.github/workflows/codacy-analysis.yml +++ b/.github/workflows/codacy-analysis.yml @@ -19,27 +19,29 @@ jobs: name: Codacy Security Scan runs-on: ubuntu-latest steps: - # Checkout the repository to the GitHub Actions runner + # Checkout the repository to the GitHub Actions runner. - name: Checkout code uses: actions/checkout@v4 - # Execute Codacy Analysis CLI and generate a SARIF output with the security issues identified during the analysis + # Execute Codacy Analysis CLI and generate a SARIF output + # with the security issues identified during the analysis. - name: Run Codacy Analysis CLI uses: codacy/codacy-analysis-cli-action@master with: - # Check https://github.com/codacy/codacy-analysis-cli#project-token to get your project token from your Codacy repository - # You can also omit the token and run the tools that support default configurations + # Check https://github.com/codacy/codacy-analysis-cli#project-token + # to get your project token from your Codacy repository. + # You can also omit the token and run the tools that support default configurations. project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} verbose: true output: results.sarif format: sarif - # Adjust severity of non-security issues + # Adjust severity of non-security issues. gh-code-scanning-compat: true - # Force 0 exit code to allow SARIF file generation - # This will handover control about PR rejection to the GitHub side + # Force 0 exit code to allow SARIF file generation. + # This will handover control about PR rejection to the GitHub side. max-allowed-issues: 2147483647 - # Upload the SARIF file generated in the previous step + # Upload the SARIF file generated in the previous step. - name: Upload SARIF results file uses: github/codeql-action/upload-sarif@v3 with: diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index ce25ff7..81c5cfb 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -1,5 +1,6 @@ # This workflows will upload a Python Package using Twine when a release is created -# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries +# For more information see: +# https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries name: Upload Python Package diff --git a/pyrad/packet.py b/pyrad/packet.py index dc009a6..4564f8f 100644 --- a/pyrad/packet.py +++ b/pyrad/packet.py @@ -404,6 +404,7 @@ def ReplyPacket(self): :rtype: string """ assert(self.authenticator) + assert(self.secret is not None) if self.message_authenticator: @@ -641,7 +642,7 @@ def SaltDecrypt(self, value): class AuthPacket(Packet): def __init__(self, code=AccessRequest, id=None, secret=b'', - authenticator=None, auth_type='pap', **attributes): + authenticator=None, auth_type='pap', **attributes): """Constructor :param code: packet type code @@ -740,8 +741,8 @@ def PwDecrypt(self, password): # If the shared secret with the client is not the same, then de-obfuscating the password # field may yield illegal UTF-8 bytes. Therefore, in order not to provoke an Exception here - # (which would be not consistently generated since this will depend on the random data chosen - # by the client) we simply ignore un-parsable UTF-8 sequences. + # (which would be not consistently generated since this will depend on the random data + # chosen by the client) we simply ignore un-parsable UTF-8 sequences. return pw.decode('utf-8', errors="ignore") def PwCrypt(self, password): diff --git a/pyrad/tools.py b/pyrad/tools.py index 0ad3cb9..303eb7a 100644 --- a/pyrad/tools.py +++ b/pyrad/tools.py @@ -144,6 +144,7 @@ def EncodeInteger(num, format='!I'): raise TypeError('Can not encode non-integer as integer') return struct.pack(format, num) + def EncodeInteger64(num, format='!Q'): try: num = int(num) @@ -151,6 +152,7 @@ def EncodeInteger64(num, format='!Q'): raise TypeError('Can not encode non-integer as integer64') return struct.pack(format, num) + def EncodeDate(num): if not isinstance(num, int): raise TypeError('Can not encode non-integer as date')