From ca7aff36d42f9065b31ee1be6259afed9afbe2cb Mon Sep 17 00:00:00 2001 From: Sidney Andrews Date: Mon, 14 Oct 2024 19:54:29 +0000 Subject: [PATCH] Initial commit --- .github/SECURITY.md | 41 +++++++++++++++++ .github/workflows/clone.yml | 83 +++++++++++++++++++++++++++++++++++ .github/workflows/release.yml | 35 +++++++++++++++ .github/workflows/replace.cs | 7 +++ LICENSE | 21 +++++++++ README.md | 2 - readme.md | 8 ++++ 7 files changed, 195 insertions(+), 2 deletions(-) create mode 100644 .github/SECURITY.md create mode 100644 .github/workflows/clone.yml create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/replace.cs create mode 100644 LICENSE delete mode 100644 README.md create mode 100644 readme.md diff --git a/.github/SECURITY.md b/.github/SECURITY.md new file mode 100644 index 0000000..96d73bc --- /dev/null +++ b/.github/SECURITY.md @@ -0,0 +1,41 @@ + + +## Security + +Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/Microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet) and [Xamarin](https://github.com/xamarin). + +If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://aka.ms/security.md/definition), please report it to us as described below. + +## Reporting Security Issues + +**Please do not report security vulnerabilities through public GitHub issues.** + +Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://aka.ms/security.md/msrc/create-report). + +If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://aka.ms/security.md/msrc/pgp). + +You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://www.microsoft.com/msrc). + +Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue: + + * Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.) + * Full paths of source file(s) related to the manifestation of the issue + * The location of the affected source code (tag/branch/commit or direct URL) + * Any special configuration required to reproduce the issue + * Step-by-step instructions to reproduce the issue + * Proof-of-concept or exploit code (if possible) + * Impact of the issue, including how an attacker might exploit the issue + +This information will help us triage your report more quickly. + +If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://aka.ms/security.md/msrc/bounty) page for more details about our active programs. + +## Preferred Languages + +We prefer all communications to be in English. + +## Policy + +Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://aka.ms/security.md/cvd). + + \ No newline at end of file diff --git a/.github/workflows/clone.yml b/.github/workflows/clone.yml new file mode 100644 index 0000000..7901825 --- /dev/null +++ b/.github/workflows/clone.yml @@ -0,0 +1,83 @@ +name: Pull latest changes from quickstart repository +on: + workflow_dispatch: + schedule: + - cron: '0 13 * * 1' +jobs: + pull-request-source-repo: + name: Create pull request + runs-on: ubuntu-latest + env: + WORKING_BRANCH: auto + steps: + - name: Get GitHub App token + uses: actions/create-github-app-token@v1 + id: app-token + with: + app-id: ${{ secrets.PORTAL_QUICKSTART_SYNCHRONIZER_APP_ID }} + private-key: ${{ secrets.PORTAL_QUICKSTART_SYNCHRONIZER_PRIVATE_KEY }} + - name: Checkout source repository + uses: actions/checkout@v4 + with: + repository: azure-samples/cosmos-db-table-dotnet-quickstart + ref: main + path: source + - name: Checkout target repository + uses: actions/checkout@v4 + with: + token: ${{ steps.app-token.outputs.token }} + ref: ${{ github.head_ref }} + path: target + - name: Get GitHub App User ID + id: get-user-id + env: + GITHUB_TOKEN: ${{ steps.app-token.outputs.token }} + run: echo "user-id=$(gh api "/users/${{ steps.app-token.outputs.app-slug }}[bot]" --jq .id)" >> "$GITHUB_OUTPUT" + - name: Configure git + working-directory: target + run: | + git config --global user.name '${{ steps.app-token.outputs.app-slug }}[bot]' + git config --global user.email '${{ steps.get-user-id.outputs.user-id }}+${{ steps.app-token.outputs.app-slug }}[bot]@users.noreply.github.com>' + - name: Generate date variables + run: | + echo "CURRENT_DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV + echo "WORKING_BRANCH=auto-$(date +'%Y%m%d%H%M%S')" >> $GITHUB_ENV + - name: Create working branch + working-directory: target + run: git checkout -b $WORKING_BRANCH + - name: Copy source to target + run: cp -ra source/src/. target/ + - name: Change text content + working-directory: target + run: | + content=$(cat .github/workflows/replace.cs) + awk -v content="$content" ' + BEGIN { in_block = 0 } + /^\s*\/\/ / { in_block = 1; print content; next } + /^\s*\/\/ <\/create_client>/ { in_block = 0; next } + !in_block { print } + ' web/Program.cs > web/Program.tmp.cs && mv web/Program.tmp.cs web/Program.cs + - name: Add changes to git + working-directory: target + run: | + git add . + - name: Check if files are changed + id: check-files + working-directory: target + run: | + echo "status=$(git diff --shortstat --staged)" >> $GITHUB_OUTPUT + - name: Commit and push changes + if: ${{ steps.check-files.outputs.status != '' }} + working-directory: target + run: | + git commit -m "Automatically generated commit" + git push --set-upstream origin $WORKING_BRANCH + - name: Create auto-merge pull request + if: ${{ steps.check-files.outputs.status != '' }} + working-directory: target + env: + GITHUB_TOKEN: ${{ steps.app-token.outputs.token }} + run: | + url=$(gh pr create --title "[AUTO] $CURRENT_DATE | Merge latest from source repo" --body "${{ steps.check-files.outputs.status}}" --base main --head $WORKING_BRANCH) + gh pr merge --auto --merge $url + echo $url diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..ab8bfcc --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,35 @@ +name: Create release for default branch +on: + workflow_dispatch: + push: + branches: + - main +jobs: + create-release: + name: Create release + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Get GitHub App token + uses: actions/create-github-app-token@v1 + id: app-token + with: + app-id: ${{ secrets.PORTAL_QUICKSTART_SYNCHRONIZER_APP_ID }} + private-key: ${{ secrets.PORTAL_QUICKSTART_SYNCHRONIZER_PRIVATE_KEY }} + - name: Generate output + id: generate + run: | + echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT + echo "tag=release-$(date +'%Y%m%d%H%M%S')" >> $GITHUB_OUTPUT + - name: Create compressed folder + run: | + mkdir out + git archive --format=zip --output out/project.zip main + - name: Push release + env: + GITHUB_TOKEN: ${{ steps.app-token.outputs.token }} + run: | + gh release create ${{ steps.generate.outputs.tag }} \ + 'out/project.zip#Project folder' \ + --title 'Release ${{ steps.generate.outputs.date }}' diff --git a/.github/workflows/replace.cs b/.github/workflows/replace.cs new file mode 100644 index 0000000..b7895d1 --- /dev/null +++ b/.github/workflows/replace.cs @@ -0,0 +1,7 @@ + TableServiceClient serviceClient = new( + connectionString: "" + ); + + TableClient client = serviceClient.GetTableClient( + tableName: "" + ); \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..7965606 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ + MIT License + + Copyright (c) Microsoft Corporation. + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE \ No newline at end of file diff --git a/README.md b/README.md deleted file mode 100644 index 0bd86c4..0000000 --- a/README.md +++ /dev/null @@ -1,2 +0,0 @@ -# quickstart-table-dotnet -Quickstart - Azure Cosmos DB for Table - .NET diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..7523789 --- /dev/null +++ b/readme.md @@ -0,0 +1,8 @@ +# Quickstart - Azure Cosmos DB for Table - .NET + +Sample ASP.NET web application using Azure Cosmos DB for NoSQL. + +| Task | Link | +| --- | --- | +| Downloaded latest source code | | +| Open in GitHub Codespaces | |