From 252d83fcaf19eaac6b4eaaac438e56b54be9d015 Mon Sep 17 00:00:00 2001 From: Mikhail Shashin Date: Mon, 8 Jul 2024 18:50:01 +0300 Subject: [PATCH 1/7] Remove unnecessary directives --- Models/BookEntry.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Models/BookEntry.cs b/Models/BookEntry.cs index ede3ecb..7c53007 100644 --- a/Models/BookEntry.cs +++ b/Models/BookEntry.cs @@ -1,5 +1,3 @@ -using System; -using System.Collections.Generic; using System.ComponentModel; using System.ComponentModel.DataAnnotations; using Microsoft.AspNetCore.Mvc; @@ -41,7 +39,7 @@ public class BookEntry [DisplayName("Комната")] public string? Room { get; set; } = string.Empty; - [HiddenInput(DisplayValue = false)] + [HiddenInput(DisplayValue = false)] public string Status { get; set; } = string.Empty; public override string ToString() @@ -49,4 +47,4 @@ public override string ToString() // Used for full-text search return $"Entry: {Name} {Department} {Mail} {Room}"; } -} \ No newline at end of file +} From 3c5631470c372b15a81eb3231bca8aab78123107 Mon Sep 17 00:00:00 2001 From: Mikhail Shashin Date: Mon, 8 Jul 2024 18:50:47 +0300 Subject: [PATCH 2/7] Remove unnecessary directives --- Views/PhoneBook/Index.cshtml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Views/PhoneBook/Index.cshtml b/Views/PhoneBook/Index.cshtml index 600abe9..353700b 100644 --- a/Views/PhoneBook/Index.cshtml +++ b/Views/PhoneBook/Index.cshtml @@ -1,4 +1,3 @@ -@using X.PagedList.Web.Common @using X.PagedList.Mvc.Core @using Microsoft.AspNetCore.Mvc.TagHelpers @model X.PagedList.IPagedList @@ -52,7 +51,7 @@
- @if(Model.Any()) + @if(Model.Any()) { var item = Model.First(); @@ -158,4 +157,4 @@ })
-Страница @(Model.PageCount < Model.PageNumber ? 0 : Model.PageNumber) из @Model.PageCount \ No newline at end of file +Страница @(Model.PageCount < Model.PageNumber ? 0 : Model.PageNumber) из @Model.PageCount From faac4654322a340dcced0baa2b7c97683f839c7d Mon Sep 17 00:00:00 2001 From: Mikhail Shashin Date: Mon, 8 Jul 2024 18:52:39 +0300 Subject: [PATCH 3/7] Add finding rules for Department and CityPhoneNumber --- Controllers/PhoneBookController.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Controllers/PhoneBookController.cs b/Controllers/PhoneBookController.cs index 284e883..084b6f6 100644 --- a/Controllers/PhoneBookController.cs +++ b/Controllers/PhoneBookController.cs @@ -18,7 +18,7 @@ public PhoneBookController(PhonebookContext context) } [AllowAnonymous] - public async Task Index(string searchString, string currentFilter, int? cPage) + public async Task Index(string? searchString, string? currentFilter, int? cPage) { if (searchString != null) { @@ -37,9 +37,11 @@ public async Task Index(string searchString, string currentFilter { entriesQuery = entriesQuery.Where(e => e.Name.Contains(searchString) || + e.Department.Contains(searchString) || e.Mail.Contains(searchString) || e.Room.Contains(searchString) || e.LocalPhoneNumber.Contains(searchString) || + e.CityPhoneNumber.Contains(searchString) || e.PersonnelNumber.Contains(searchString)); } @@ -78,7 +80,7 @@ public IActionResult Create() } // POST: PhoneBook/Create - // To protect from overposting attacks, please enable the specific properties you want to bind to, for + // To protect from overposting attacks, please enable the specific properties you want to bind to, for // more details see http://go.microsoft.com/fwlink/?LinkId=317598. [HttpPost] [ValidateAntiForgeryToken] @@ -148,7 +150,7 @@ public async Task Edit(int id, [Bind("Id,PersonnelNumber,Name,Pos } return View(bookEntry); } - + // GET: PhoneBook/Delete/5 public async Task Delete(int? id) { @@ -182,7 +184,7 @@ private bool BookEntryExists(int id) { return _context.Entries.Any(e => e.Id == id); } - + // Valid only if personnelNumber is unique private bool VerifyPersonnelNumber(string personnelNumber, int id) { From d8f67ac59f48a419e2279de7444e282c7fb85d69 Mon Sep 17 00:00:00 2001 From: Mikhail Shashin Date: Mon, 8 Jul 2024 18:54:21 +0300 Subject: [PATCH 4/7] Update dependencies --- PhoneEdit.csproj | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/PhoneEdit.csproj b/PhoneEdit.csproj index 6bce253..f9efe2b 100644 --- a/PhoneEdit.csproj +++ b/PhoneEdit.csproj @@ -9,22 +9,22 @@ - - - - - - - + + + + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - + + + + + From 4d2ef37d344a9b806e059b48eb0226c82f3ec527 Mon Sep 17 00:00:00 2001 From: Mikhail Shashin Date: Mon, 8 Jul 2024 19:05:05 +0300 Subject: [PATCH 5/7] Update docker-publish.yml --- .github/workflows/docker-publish.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 1613e41..7cfe6ed 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -24,9 +24,7 @@ jobs: - name: Install cosign if: github.event_name != 'pull_request' - uses: sigstore/cosign-installer@6e04d228eb30da1757ee4e1dd75a0ec73a653e06 #v3.1.1 - with: - cosign-release: 'v2.1.1' + uses: sigstore/cosign-installer@v3.5.0 - name: Set up Docker Buildx uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0 From 1f044922f849af63cea2f18b32c58d22a4572238 Mon Sep 17 00:00:00 2001 From: Mikhail Shashin Date: Mon, 8 Jul 2024 19:16:40 +0300 Subject: [PATCH 6/7] Update docker-publish.yml (#11) --- .github/workflows/docker-publish.yml | 31 +++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 7cfe6ed..0c1dd18 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -1,34 +1,50 @@ name: Docker Packages +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + on: release: types: [published] env: + # Use docker.io for Docker Hub if empty REGISTRY: ${{ vars.REGISTRY }} + jobs: Build-PhoneEdit: environment: PhoneEditApplication - + runs-on: ubuntu-latest - + permissions: contents: read packages: write + # This is used to complete the identity challenge + # with sigstore/fulcio when running outside of PRs. id-token: write steps: - name: Checkout repository uses: actions/checkout@v3 - - name: Install cosign + # Install the cosign tool except on PR + # https://github.com/sigstore/cosign-installer + - name: Install Cosign if: github.event_name != 'pull_request' uses: sigstore/cosign-installer@v3.5.0 + # Set up BuildKit Docker container builder to be able to build + # multi-platform images and export cache + # https://github.com/docker/setup-buildx-action - name: Set up Docker Buildx uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0 + # Login against a Docker registry except on PR + # https://github.com/docker/login-action - name: Log into registry ${{ env.REGISTRY }} if: github.event_name != 'pull_request' uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0 @@ -37,12 +53,16 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GH_TOKEN }} + # Extract metadata (tags, labels) for Docker + # https://github.com/docker/metadata-action - name: Extract Docker metadata id: meta uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0 with: images: ${{ env.REGISTRY }}/${{ github.actor }}/${{ vars.IMAGE_NAME }} + # Build and push Docker image with Buildx (don't push on PR) + # https://github.com/docker/build-push-action - name: Build and push PhoneEdit Docker image id: build-and-push uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0 @@ -54,6 +74,11 @@ jobs: cache-from: type=gha cache-to: type=gha,mode=max + # Sign the resulting Docker image digest except on PRs. + # This will only write to the public Rekor transparency log when the Docker + # repository is public to avoid leaking data. If you would like to publish + # transparency data even for private images, pass --force to cosign below. + # https://github.com/sigstore/cosign - name: Sign the published PhoneEdit Docker image if: ${{ github.event_name != 'pull_request' }} env: From 046c0ec5e2d91789e8f68aa1352035826103b20c Mon Sep 17 00:00:00 2001 From: Mikhail Shashin Date: Mon, 8 Jul 2024 19:22:49 +0300 Subject: [PATCH 7/7] Update docker-publish.yml --- .github/workflows/docker-publish.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 0c1dd18..bda364b 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -34,8 +34,11 @@ jobs: # Install the cosign tool except on PR # https://github.com/sigstore/cosign-installer - name: Install Cosign - if: github.event_name != 'pull_request' uses: sigstore/cosign-installer@v3.5.0 + with: + cosign-release: 'v2.2.4' + - name: Check install! + run: cosign version # Set up BuildKit Docker container builder to be able to build # multi-platform images and export cache