Skip to content

fix(cssc): 31646926 fix 'list' command filtering by '--run-status'#40

Merged
cegraybl merged 10 commits into
feature/cssc_extfrom
cegraybl/cssc_31646926_runstatus_succeeded
Mar 21, 2025
Merged

fix(cssc): 31646926 fix 'list' command filtering by '--run-status'#40
cegraybl merged 10 commits into
feature/cssc_extfrom
cegraybl/cssc_31646926_runstatus_succeeded

Conversation

@cegraybl
Copy link
Copy Markdown

@cegraybl cegraybl commented Mar 21, 2025

Fix filtering on the list command by --run-status to make it correct once again.
Now the --run-status will filter the image status depending on the final status of both the scan and patch instead of only one of them. Meaning that for an image to be marked as FAILED scan or patch have to be FAILED, for an image to be marked as SUCCEEDED both scan and patch have to be SUCCEEDED or SKIPPED as that is treated as a successful execution, and for an image to be marked as SKIPPED the scan has to be SUCCEEDED and the patch has to be SKIPPED.

This PR also includes a unit test to catch issues with the filtering.

In addition, includes fixes for unit tests that are run without azure credentials, adding the required mocks to avoid that dependency.

Some example output:

$ az acr supply-chain workflow list --run-status succeeded ...
Listing images that have been scanned and/or patched in the last 2 days
Total images: 17
[
  {
    "image": "citest:powershell_lts-7.2-ubuntu-focal",
    "last_patched_image": "citest:powershell_lts-7.2-ubuntu-focal-1",
    "patch_date": "---Not Available---",
    "patch_skipped_reason": "no vulnerability found in the image citest:powershell_lts-7.2-ubuntu-focal-1",
    "patch_status": "Skipped",
    "patch_task_ID": "---Not Available---",
    "scan_date": "2025-03-20T22:58:29.101178+00:00",
    "scan_status": "Succeeded",
    "scan_task_ID": "dt3h3",
    "workflow_type": "continuouspatchv1"
  },
  {
    "image": "import:ubuntu-jammy-20240111",
    "last_patched_image": "import:ubuntu-jammy-20240111-6",
    "patch_date": "---Not Available---",
    "patch_skipped_reason": "no vulnerability found in the image import:ubuntu-jammy-20240111-6\r",
    "patch_status": "Skipped",
    "patch_task_ID": "---Not Available---",
    "scan_date": "2025-03-20T22:58:26.024742+00:00",
    "scan_status": "Succeeded",
    "scan_task_ID": "dt3h2",
    "workflow_type": "continuouspatchv1"
  },
  {
    "image": "import:pytorch-2.2.2-1-azl3.0.20240727-amd64",
    "last_patched_image": "import:pytorch-2.2.2-1-azl3.0.20240727-amd64-5",
    "patch_date": "2025-03-20T22:59:10.231822+00:00",
    "patch_status": "Succeeded",
    "patch_task_ID": "dt3h8",
    "scan_date": "2025-03-20T22:58:21.199712+00:00",
    "scan_status": "Succeeded",
    "scan_task_ID": "dt3h1",
    "workflow_type": "continuouspatchv1"
  },
  {
    "image": "import:openmpi-4.1.5-1-azl3.0.20240727-amd64",
    "last_patched_image": "import:openmpi-4.1.5-1-azl3.0.20240727-amd64-6",
    "patch_date": "2025-03-20T22:58:54.001933+00:00",
    "patch_status": "Succeeded",
    "patch_task_ID": "dt3h6",
    "scan_date": "2025-03-20T22:58:18.284315+00:00",
    "scan_status": "Succeeded",
    "scan_task_ID": "dt3h0",
    "workflow_type": "continuouspatchv1"
  },
...
$ az acr supply-chain workflow list --run-status skipped ...
Listing images that have been scanned and/or patched in the last 2 days
Total images: 14
[
  {
    "image": "citest:powershell_ubuntu-22.04",
    "last_patched_image": "citest:powershell_ubuntu-22.04-1",
    "patch_date": "---Not Available---",
    "patch_skipped_reason": "no vulnerability found in the image citest:powershell_ubuntu-22.04-1",
    "patch_status": "Skipped",
    "patch_task_ID": "---Not Available---",
    "scan_date": "2025-03-20T22:59:05.572797+00:00",
    "scan_status": "Succeeded",
    "scan_task_ID": "dt3h7",
    "workflow_type": "continuouspatchv1"
  },
  {
    "image": "citest:powershell_ubuntu-20.04",
    "last_patched_image": "citest:powershell_ubuntu-20.04-1",
    "patch_date": "---Not Available---",
    "patch_skipped_reason": "no vulnerability found in the image citest:powershell_ubuntu-20.04-1",
    "patch_status": "Skipped",
    "patch_task_ID": "---Not Available---",
    "scan_date": "2025-03-20T22:58:32.219472+00:00",
    "scan_status": "Succeeded",
    "scan_task_ID": "dt3h4",
    "workflow_type": "continuouspatchv1"
  },
...
$ az acr supply-chain workflow list --run-status failed ...
Listing images that have been scanned and/or patched in the last 2 days
Total images: 4
[
  {
    "image": "import:dotnet-samples-aspnetapp-jammy-chiseled-composite-amd64",
    "last_patched_image": "---No patch image available---",
    "patch_date": "2025-03-20T22:57:59.380189+00:00",
    "patch_error_reason": "ERROR: process \"apt-get update\" did not complete successfully: exit code: 1\nError: failed during run, err: exit status 1\r\nError: process \"apt-get update\" did not complete successfully: exit code: 1",
    "patch_status": "Failed",
    "patch_task_ID": "dt3gu",
    "scan_date": "2025-03-20T22:57:19.033179+00:00",
    "scan_status": "Succeeded",
    "scan_task_ID": "dt3gn",
    "workflow_type": "continuouspatchv1"
  },
  {
    "image": "python-cache:3.12.3-2-azl3.0.20240824-amd64",
    "last_patched_image": "---No patch image available---",
    "patch_date": "2025-03-20T22:57:48.215233+00:00",
    "patch_error_reason": "Error: failed during run, err: exit status 1\r\nerror parsing HTTP 429 response body: unexpected end of JSON input: \"\"",
    "patch_status": "Failed",
    "patch_task_ID": "dt3gs",
    "scan_date": "2025-03-20T22:57:12.966699+00:00",
    "scan_status": "Succeeded",
    "scan_task_ID": "dt3gk",
    "workflow_type": "continuouspatchv1"
  },
...

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes the filtering logic on the "list" command by updating how image statuses are determined based on both the scan and patch tasks. It consolidates changes in workflow status filtering, updates test cases (including renaming and parameter adjustments), and refines the retrieval and filtering of task logs to better reflect the intended behavior.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
src/acrcssc/azext_acrcssc/tests/latest/test_workflow_status.py Renames a test function and updates task generation parameters to better simulate patch task behavior.
src/acrcssc/azext_acrcssc/helper/_workflow_status.py Introduces a new workflow_status_filter parameter and adds a filtering function for taskruns.
src/acrcssc/azext_acrcssc/helper/_taskoperations.py Adjusts the call to from_taskrun to pass workflow_status_filter for consistent filtering.
src/acrcssc/azext_acrcssc/tests/latest/test_helper_taskoperations.py Updates mock dependencies to support changes in task retrieval and filtering.
Comments suppressed due to low confidence (1)

src/acrcssc/azext_acrcssc/helper/_workflow_status.py:345

  • The filtering condition for non-SKIPPED statuses relies solely on workflow.status() (which returns the run_status) rather than checking both the scan_status and patch_status. Consider updating this condition so that it properly filters workflows based on whether either scan_status or patch_status matches the intended filter.
for key, workflow in workflows.items() if workflow.status() == workflow_status_filter

@cegraybl cegraybl merged commit fc0beb6 into feature/cssc_ext Mar 21, 2025
@cegraybl cegraybl deleted the cegraybl/cssc_31646926_runstatus_succeeded branch April 23, 2025 17:10
cegraybl added a commit that referenced this pull request Apr 23, 2025
Fix filtering on the `list` command by `--run-status` to make it correct
once again.
Now the `--run-status` will filter the image status depending on the
final status of both the scan and patch instead of only one of them.
Meaning that for an image to be marked as `FAILED` scan or patch have to
be `FAILED`, for an image to be marked as `SUCCEEDED` both scan and
patch have to be `SUCCEEDED` or `SKIPPED` as that is treated as a
successful execution, and for an image to be marked as `SKIPPED` the
scan has to be `SUCCEEDED` and the patch has to be `SKIPPED`.

This PR also includes a unit test to catch issues with the filtering.

In addition, includes fixes for unit tests that are run without azure
credentials, adding the required mocks to avoid that dependency.
cegraybl added a commit that referenced this pull request Apr 24, 2025
Fix filtering on the `list` command by `--run-status` to make it correct
once again.
Now the `--run-status` will filter the image status depending on the
final status of both the scan and patch instead of only one of them.
Meaning that for an image to be marked as `FAILED` scan or patch have to
be `FAILED`, for an image to be marked as `SUCCEEDED` both scan and
patch have to be `SUCCEEDED` or `SKIPPED` as that is treated as a
successful execution, and for an image to be marked as `SKIPPED` the
scan has to be `SUCCEEDED` and the patch has to be `SKIPPED`.

This PR also includes a unit test to catch issues with the filtering.

In addition, includes fixes for unit tests that are run without azure
credentials, adding the required mocks to avoid that dependency.
mabelegba pushed a commit that referenced this pull request Nov 25, 2025
* Upstream Merge

* Merge from workload-orchestration : Added Example in Description (#34)

* Merge from workload-orchestration : Fixed Example

* Fixed Example for SolutionTemplateVersion

* Made Changes for command-change CI fix'

* Reset Version 1.0.0b1

* Added Bulk and Diagnostics Back (#35)

Co-authored-by: Atharva Udapure <audapure@microsoft.com>

* Added Bulk Solution Example (#36)

* Added Bulk and Diagnostics Back

* Changes

---------

Co-authored-by: Atharva Udapure <audapure@microsoft.com>

* Fixed Solution Template Linter Issue

* Added Integration Tests Framework for WorkloadOrchestration #37

Co-authored-by: Atharva Udapure <audapure@microsoft.com>

* Added ServiceName  (#38)

* Added Tests

* Made Changes on ServiceName

---------

Co-authored-by: Atharva Udapure <audapure@microsoft.com>

* Added Full Target Solution Tests (#39)

* Added Tests

* Made Changes on ServiceName

* Nit Changes

* Made Changes for ContextLookup

---------

Co-authored-by: Atharva Udapure <audapure@microsoft.com>

* Added E2E workflow Tests (#40)

* Added Tests

* Made Changes on ServiceName

* Nit Changes

* Made Changes for ContextLookup

* Added complete workflow

* Add Licence

* Added License

---------

Co-authored-by: Atharva Udapure <audapure@microsoft.com>

* Added Readme (#41)

Co-authored-by: Atharva Udapure <audapure@microsoft.com>

* Bulk Deployemnent LRO changes (#42)

* made changes

* Added change

* Added Changes in Test

* Added CLi Changes

* Added Setup

---------

Co-authored-by: Atharva Udapure <audapure@microsoft.com>

* Added Changes For Backward Compitablity (#43)

* Added Changes For Backward Compitablity

* Made changes

---------

Co-authored-by: Atharva Udapure <audapure@microsoft.com>

* Made changes (#44)

Co-authored-by: Atharva Udapure <audapure@microsoft.com>

* Target Operations API refractoring  (#47)

* Changes I made

* Make changes

* Made chnages

* Make changes

---------

Co-authored-by: Atharva Udapure <audapure@microsoft.com>

* Stable API 2025-06-01 (#48)

* Made changes

* Made Changes

---------

Co-authored-by: Atharva Udapure <audapure@microsoft.com>

* Change in ID in Targets (#50)

* Made changes

* changes

---------

Co-authored-by: Atharva Udapure <audapure@microsoft.com>

* Remove Id and Name from Target Review  (#51)

Co-authored-by: Atharva Udapure <audapure@microsoft.com>

* final bulk (#52)

Co-authored-by: Atharva Udapure <audapure@microsoft.com>

* Changes in ARG

* Added Linter Exception

* Added ITTests (#53)

Co-authored-by: Atharva Udapure <audapure@microsoft.com>

* Standardize CLI (#54)

* Made Changes

* Made Changes

* Made changes

* Added Change

* Made changes

* Made changes

* Made changes

* Made Changes

---------

Co-authored-by: Atharva Udapure <audapure@microsoft.com>

* Linter FIxes and Remove Preview

* Removed Resolved from CLI

* change in version

* made changes (#55)

Co-authored-by: Atharva Udapure <audapure@microsoft.com>

* Fixed history

---------

Co-authored-by: Atharva Udapure <audapure@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants