Skip to content

Commit

Permalink
minor codacy fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
GIC-de committed Jul 24, 2024
1 parent 1fc4fcf commit f42a57c
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
18 changes: 10 additions & 8 deletions .github/workflows/codacy-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -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

Expand Down
7 changes: 4 additions & 3 deletions pyrad/packet.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ def ReplyPacket(self):
:rtype: string
"""
assert(self.authenticator)

assert(self.secret is not None)

if self.message_authenticator:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down
2 changes: 2 additions & 0 deletions pyrad/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,15 @@ 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)
except:
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')
Expand Down

0 comments on commit f42a57c

Please sign in to comment.