Skip to content
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

[GH-165] - Prevent double Base64 encoding of profile href + Github Actions updates #166

Merged
merged 11 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions .github/actions/configure-docker/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ inputs:
runs:
using: composite
steps:
- uses: google-github-actions/auth@v0
- uses: google-github-actions/auth@v2
with:
credentials_json: ${{ inputs.gcr-token }}
- uses: google-github-actions/setup-gcloud@v1.0.1
- uses: google-github-actions/setup-gcloud@v2.1.0

# archiving leaving this "with" section, might b a handy reference at a later date.
# It was there when the above "uses" was uses: google-github-actions/setup-gcloud@v0
Expand Down
18 changes: 14 additions & 4 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ jobs:
new-version: ${{ steps.update-version.outputs.new-version }}
steps:
- name: Python Poetry Action
uses: abatilo/actions-poetry@v2.1.6
run: pipx install poetry

- uses: uwit-iam/actions/[email protected]
id: guidance
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

- uses: uwit-iam/actions/[email protected].16
- uses: uwit-iam/actions/[email protected].20
with:
github-token: ${{ env.GITHUB_TOKEN }}
github-token: ${{ secrets.GITHUB_TOKEN }}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks good, thanks!

version-guidance: ${{ steps.guidance.outputs.guidance }}
id: update-version

Expand All @@ -49,7 +49,17 @@ jobs:
with:
ref: ${{ github.event.pull_request.head.ref }}

- uses: abatilo/[email protected]
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: Install Poetry with pip
run: |
python -m pip install --upgrade pip
python -m pip install poetry
poetry --version

- run: |
sudo apt-get -y install jq
poetry run pip install tox uw-it-build-fingerprinter
Expand Down
20 changes: 19 additions & 1 deletion husky_directory/models/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,25 @@ class Person(DirectoryBaseModel):

@validator("href")
def b64_encode_href(cls, value: str) -> str:
return base64.b64encode(value.encode("UTF-8")).decode("UTF-8")
"""
Base64 encode href only if not already encoded.
Prevents double-encoding after browser back navigation when href
from previous page state is already encoded.
"""
encoding = "UTF-8"
if not cls._is_base64_encoded(value, encoding):
return base64.b64encode(value.encode(encoding)).decode(encoding)
return value

@staticmethod
def _is_base64_encoded(value: str, encoding: str = "UTF-8") -> bool:
"""
Check if a string is already base64 encoded.
"""
try:
return base64.b64decode(value.encode(encoding)).decode(encoding) is not None
except (ValueError, UnicodeDecodeError):
return False

@validator("sort_key", always=True)
def set_default_sort_key(cls, v: Optional[str], values: Dict):
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "uw-husky-directory"
version = "2.2.7"
version = "2.2.8"
description = "An updated version of the UW Directory"
authors = ["Thomas Thorogood <[email protected]>"]
license = "MIT"
Expand Down
Loading