From 8be59fc2addafd984309b68b71906c467ab1088e Mon Sep 17 00:00:00 2001 From: Mend Renovate Date: Mon, 17 Jul 2023 17:53:47 +0200 Subject: [PATCH 1/5] chore(deps): update dependency cryptography to v41.0.2 [security] (#550) --- authenticating-users/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/authenticating-users/requirements.txt b/authenticating-users/requirements.txt index aa163f59..0d4a3c36 100644 --- a/authenticating-users/requirements.txt +++ b/authenticating-users/requirements.txt @@ -1,6 +1,6 @@ # [START getting_started_requirements] Flask==2.2.5 -cryptography==41.0.0 +cryptography==41.0.2 python-jose[cryptography]==3.3.0 requests==2.31.0 # [END getting_started_requirements] From 21d4d6bc33a457dc91af0199cffd6211f1fff5a2 Mon Sep 17 00:00:00 2001 From: Jennifer Davis Date: Thu, 22 Aug 2024 13:01:55 -0700 Subject: [PATCH 2/5] fix: update libraries and python for the base image (#570) * fix: update libraries and python for the base image * fix:update python to python3 * fix: removing the python installation and using what's already installed * fix: resolve error around the use of apt instead of apt-get --- .kokoro/docker/Dockerfile | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/.kokoro/docker/Dockerfile b/.kokoro/docker/Dockerfile index 6b6c19f1..accdd0bf 100644 --- a/.kokoro/docker/Dockerfile +++ b/.kokoro/docker/Dockerfile @@ -15,8 +15,8 @@ FROM gcr.io/cloud-devrel-kokoro-resources/python-base:latest # Install libraries needed by third-party python packages that we depend on. -RUN apt update \ - && apt install -y \ +RUN apt-get update \ + && apt-get install -y \ graphviz \ libcurl4-openssl-dev \ libffi-dev \ @@ -30,32 +30,19 @@ RUN apt update \ libxml2-dev \ libxslt1-dev \ openssl \ - portaudio19-dev \ - python-pyaudio \ zlib1g-dev \ - && apt clean + && apt-get clean -###################### Install python 3.7.12 - -# Download python 3.7.12 -RUN wget https://www.python.org/ftp/python/3.7.12/Python-3.7.12.tgz - -# Extract files -RUN tar -xvf Python-3.7.12.tgz - -# Install python 3.7.12 -RUN ./Python-3.7.12/configure --enable-optimizations -RUN make altinstall ###################### Check python version -RUN python --version -RUN which python +RUN python3 --version +RUN which python3 # Setup Cloud SDK -ENV CLOUD_SDK_VERSION 369.0.0 +ENV CLOUD_SDK_VERSION 489.0.0 # Use system python for cloud sdk. -ENV CLOUDSDK_PYTHON /usr/bin/python +ENV CLOUDSDK_PYTHON python3.12 RUN wget https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-$CLOUD_SDK_VERSION-linux-x86_64.tar.gz RUN tar xzf google-cloud-sdk-$CLOUD_SDK_VERSION-linux-x86_64.tar.gz RUN /google-cloud-sdk/install.sh From d9da8db203f7729f5da28b57be66b69084955bde Mon Sep 17 00:00:00 2001 From: Jennifer Davis Date: Thu, 22 Aug 2024 14:23:10 -0700 Subject: [PATCH 3/5] fix: rev version of python for use noxfile.py (#571) --- noxfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/noxfile.py b/noxfile.py index 68fb5a37..8f5a921c 100644 --- a/noxfile.py +++ b/noxfile.py @@ -55,7 +55,7 @@ def run_test(session, dir): success_codes=[0, 5]) -@nox.session(python="3.7") +@nox.session(python="3.12") @nox.parametrize('dir', DIRS) def run_tests(session, dir=None): """Run all tests for all directories (slow!)""" From d6097aa561c71d67c953bdeb724b4da372bd2cec Mon Sep 17 00:00:00 2001 From: bhandarivijay-png Date: Mon, 5 Jan 2026 18:43:17 +0000 Subject: [PATCH 4/5] chore: Migrate gsutil usage to gcloud storage (#584) --- optional-kubernetes-engine/Makefile | 4 ++-- optional-kubernetes-engine/README.md | 4 ++-- optional-kubernetes-engine/config.py | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/optional-kubernetes-engine/Makefile b/optional-kubernetes-engine/Makefile index f275ddf4..4c1cbf3e 100644 --- a/optional-kubernetes-engine/Makefile +++ b/optional-kubernetes-engine/Makefile @@ -12,8 +12,8 @@ create-cluster: .PHONY: create-bucket create-bucket: - gsutil mb gs://$(GCLOUD_PROJECT) - gsutil defacl set public-read gs://$(GCLOUD_PROJECT) + gcloud storage buckets create gs://$(GCLOUD_PROJECT) + gcloud storage buckets update gs://$(GCLOUD_PROJECT) --predefined-default-object-acl=public-read .PHONY: build build: diff --git a/optional-kubernetes-engine/README.md b/optional-kubernetes-engine/README.md index e3c17236..9acb98b4 100644 --- a/optional-kubernetes-engine/README.md +++ b/optional-kubernetes-engine/README.md @@ -36,8 +36,8 @@ Alternatively, you can use make: The bookshelf application uses [Google Cloud Storage](https://cloud.google.com/storage) to store image files. Create a bucket for your project: - gsutil mb gs:// - gsutil defacl set public-read gs:// + gcloud storage buckets create gs:// + gcloud storage buckets update gs:// --predefined-default-object-acl=public-read Alternatively, you can use make: diff --git a/optional-kubernetes-engine/config.py b/optional-kubernetes-engine/config.py index 0fd601ed..7da9b4cc 100644 --- a/optional-kubernetes-engine/config.py +++ b/optional-kubernetes-engine/config.py @@ -78,12 +78,12 @@ # Typically, you'll name your bucket the same as your project. To create a # bucket: # -# $ gsutil mb gs:// +# $ gcloud storage buckets create gs:// # # You also need to make sure that the default ACL is set to public-read, # otherwise users will not be able to see their upload images: # -# $ gsutil defacl set public-read gs:// +# $ gcloud storage buckets update --predefined-default-object-acl=public-read gs:// # # You can adjust the max content length and allow extensions settings to allow # larger or more varied file types if desired. From 08418ec52153b88a7148abca245ea29eb352f8df Mon Sep 17 00:00:00 2001 From: Jennifer Davis Date: Thu, 15 Jan 2026 13:06:12 -0800 Subject: [PATCH 5/5] fix: modernize background app (#572) * fix: modernize background app * fix: attempt to fix linting issues * fix: resolve server-side cross-site scripting * fix: resolve lint issue with import order. * chore: add temporary use of storage to check if auth is working correctly. * fix: moving the bucket_name to the right level of indentation. * tmp: adding an assert to use the bucket variable that should be removed. * fix: based on https://github.com/pallets/flask/pull/5223/files moving to the use of markupsafe for escape * fix: import order * fix: really fix the library order --- background/app/app.yaml | 2 +- background/app/main.py | 18 ++++++++---------- background/app/main_test.py | 7 +++++-- background/app/requirements.txt | 6 +++--- 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/background/app/app.yaml b/background/app/app.yaml index fb63451a..02c0651c 100644 --- a/background/app/app.yaml +++ b/background/app/app.yaml @@ -13,5 +13,5 @@ # limitations under the License. # [START getting_started_background_config] -runtime: python37 +runtime: python312 # [END getting_started_background_config] diff --git a/background/app/main.py b/background/app/main.py index 5474d54c..fad93d46 100644 --- a/background/app/main.py +++ b/background/app/main.py @@ -21,8 +21,8 @@ import os from flask import Flask, redirect, render_template, request -from google.cloud import firestore -from google.cloud import pubsub +from google.cloud import firestore, pubsub +from markupsafe import escape app = Flask(__name__) @@ -61,15 +61,13 @@ def translate(): language (form field 'lang'), by sending a PubSub message to a topic. """ source_string = request.form.get("v", "") - to_language = request.form.get("lang", "") + to_language = escape(request.form.get("lang", "")) if source_string == "": - error_message = "Empty value" - return error_message, 400 + return "Invalid request, you must provide a value.", 400 if to_language not in ACCEPTABLE_LANGUAGES: - error_message = "Unsupported language: {}".format(to_language) - return error_message, 400 + return f"Unsupported language: {to_language}", 400 message = { "Original": source_string, @@ -78,11 +76,11 @@ def translate(): "OriginalLanguage": "", } - topic_name = "projects/{}/topics/{}".format( - os.getenv("GOOGLE_CLOUD_PROJECT"), "translate" + topic_name = ( + f"projects/{os.getenv('GOOGLE_CLOUD_PROJECT')}/topics/translate" ) publisher.publish( - topic=topic_name, data=json.dumps(message).encode("utf8") + topic=topic_name, data=json.dumps(message).encode("utf-8") ) return redirect("/") diff --git a/background/app/main_test.py b/background/app/main_test.py index f3bf28c2..41b529d3 100644 --- a/background/app/main_test.py +++ b/background/app/main_test.py @@ -16,8 +16,7 @@ import uuid import google.auth -from google.cloud import firestore -from google.cloud import pubsub +from google.cloud import firestore, pubsub, storage import main import pytest @@ -39,7 +38,10 @@ def clear_collection(collection): for doc in collection.stream(): doc.reference.delete() + bucket_name = 'system-test-bucket' client = firestore.Client() + storage_client = storage.Client() + bucket = storage_client.bucket(bucket_name) translations = client.collection("translations") clear_collection(translations) translations.add( @@ -51,6 +53,7 @@ def clear_collection(collection): }, document_id="test translation", ) + assert bucket in locals() yield client diff --git a/background/app/requirements.txt b/background/app/requirements.txt index 7cfba806..f70d16b7 100644 --- a/background/app/requirements.txt +++ b/background/app/requirements.txt @@ -1,3 +1,3 @@ -google-cloud-firestore==2.11.1 -google-cloud-pubsub==2.16.1 -flask==2.2.5 +google-cloud-firestore==2.18.0 +google-cloud-pubsub==2.23.0 +flask==3.0.3