Skip to content

Commit 3d92a8a

Browse files
authored
fix: revert confcom 1.5.0 (#9483)
* fix: revert confcom 1.5.0 * style: cannot modify index
1 parent 8546687 commit 3d92a8a

17 files changed

+55
-907
lines changed

linter_exclusions.yml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3504,15 +3504,3 @@ neon postgres organization:
35043504
neon postgres project:
35053505
rule_exclusions:
35063506
- require_wait_command_if_no_wait
3507-
3508-
confcom fragment push:
3509-
parameters:
3510-
signed_fragment:
3511-
rule_exclusions:
3512-
- no_positional_parameters
3513-
3514-
confcom fragment attach:
3515-
parameters:
3516-
signed_fragment:
3517-
rule_exclusions:
3518-
- no_positional_parameters

src/confcom/HISTORY.rst

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,6 @@
33
Release History
44
===============
55

6-
1.5.0
7-
++++++
8-
* restored the behaviour of --upload-fragment in acifragmentgen to attach to first image in input
9-
* added confcom fragment push command to allow explicit uploading of standalone fragments
10-
* added confcom fragment attach command to allow explicit uploading of image attached fragments
11-
126
1.4.5
137
++++++
148
* Drop the dependency on OPA

src/confcom/azext_confcom/_help.py

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -278,46 +278,3 @@
278278
- name: Input a Kubernetes YAML file with a custom containerd socket path
279279
text: az confcom katapolicygen --yaml "./pod.json" --containerd-pull --containerd-socket-path "/my/custom/containerd.sock"
280280
"""
281-
282-
helps[
283-
"confcom fragment"
284-
] = """
285-
type: group
286-
short-summary: Commands to handle Confidential Container Policy Fragments.
287-
"""
288-
289-
helps[
290-
"confcom fragment push"
291-
] = """
292-
type: command
293-
short-summary: Push a Confidential Container Policy Fragment to an ORAS registry
294-
295-
parameters:
296-
- name: --manifest-tag
297-
type: string
298-
short-summary: 'The reference to push the signed fragment to'
299-
300-
examples:
301-
- name: Push a signed fragment to a registry
302-
text: az confcom fragment push ./fragment.reg.cose --manifest-tag myregistry.azurecr.io/fragment:latest
303-
- name: Push the output of acifragmentgen to a registry
304-
text: az confcom acifragmentgen --chain my.cert.pem --key my_key.pem --svn "1" --namespace contoso --feed "test-feed" --input ./fragment_spec.json | az confcom fragment push --manifest-tag myregistry.azurecr.io/fragment:latest
305-
"""
306-
307-
helps[
308-
"confcom fragment attach"
309-
] = """
310-
type: command
311-
short-summary: Attach a Confidential Container Policy Fragment to an image in an ORAS registry.
312-
313-
parameters:
314-
- name: --manifest-tag
315-
type: string
316-
short-summary: 'The reference to attach the signed fragment to'
317-
318-
examples:
319-
- name: Attach a signed fragment to a registry
320-
text: az confcom fragment attach ./fragment.reg.cose --manifest-tag myregistry.azurecr.io/image:latest
321-
- name: Attach the output of acifragmentgen to a registry
322-
text: az confcom acifragmentgen --chain my.cert.pem --key my_key.pem --svn "1" --namespace contoso --feed "test-feed" --input ./fragment_spec.json | az confcom fragment attach --manifest-tag myregistry.azurecr.io/image:latest
323-
"""

src/confcom/azext_confcom/_params.py

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
# pylint: disable=line-too-long
66

77
import json
8-
import argparse
9-
import sys
108
from knack.arguments import CLIArgumentType
119
from azext_confcom._validators import (
1210
validate_params_file,
@@ -46,32 +44,6 @@ def load_arguments(self, _):
4644
c.argument("tags", tags_type)
4745
c.argument("confcom_name", confcom_name_type, options_list=["--name", "-n"])
4846

49-
with self.argument_context("confcom fragment attach") as c:
50-
c.positional(
51-
"signed_fragment",
52-
nargs='?',
53-
type=argparse.FileType('rb'),
54-
default=sys.stdin.buffer,
55-
help="Signed fragment to attach",
56-
)
57-
c.argument(
58-
"manifest_tag",
59-
help="Manifest tag for the fragment",
60-
)
61-
62-
with self.argument_context("confcom fragment push") as c:
63-
c.positional(
64-
"signed_fragment",
65-
nargs='?',
66-
type=argparse.FileType('rb'),
67-
default=sys.stdin.buffer,
68-
help="Signed fragment to push",
69-
)
70-
c.argument(
71-
"manifest_tag",
72-
help="Manifest tag for the fragment",
73-
)
74-
7547
with self.argument_context("confcom acipolicygen") as c:
7648
c.argument(
7749
"input_path",
@@ -390,13 +362,6 @@ def load_arguments(self, _):
390362
type=json.loads,
391363
help='Container definitions to include in the policy'
392364
)
393-
c.argument(
394-
"out_signed_fragment",
395-
action="store_true",
396-
default=False,
397-
required=False,
398-
help="Emit only the signed fragment bytes",
399-
)
400365

401366
with self.argument_context("confcom katapolicygen") as c:
402367
c.argument(

src/confcom/azext_confcom/command/fragment_attach.py

Lines changed: 0 additions & 46 deletions
This file was deleted.

src/confcom/azext_confcom/command/fragment_push.py

Lines changed: 0 additions & 46 deletions
This file was deleted.

src/confcom/azext_confcom/commands.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,5 @@ def load_command_table(self, _):
1111
g.custom_command("acifragmentgen", "acifragmentgen_confcom")
1212
g.custom_command("katapolicygen", "katapolicygen_confcom")
1313

14-
with self.command_group("confcom fragment") as g:
15-
g.custom_command("attach", "fragment_attach", is_preview=True)
16-
g.custom_command("push", "fragment_push", is_preview=True)
17-
1814
with self.command_group("confcom"):
1915
pass

src/confcom/azext_confcom/custom.py

Lines changed: 6 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55

66
import os
77
import sys
8-
import tempfile
9-
from typing import Optional, BinaryIO
8+
from typing import Optional
109

1110
from azext_confcom import oras_proxy, os_util, security_policy
1211
from azext_confcom._validators import resolve_stdio
@@ -23,8 +22,6 @@
2322
get_image_name, inject_policy_into_template, inject_policy_into_yaml,
2423
pretty_print_func, print_existing_policy_from_arm_template,
2524
print_existing_policy_from_yaml, print_func, str_to_sha256)
26-
from azext_confcom.command.fragment_attach import fragment_attach as _fragment_attach
27-
from azext_confcom.command.fragment_push import fragment_push as _fragment_push
2825
from knack.log import get_logger
2926
from pkg_resources import parse_version
3027

@@ -258,7 +255,6 @@ def acifragmentgen_confcom(
258255
upload_fragment: bool = False,
259256
no_print: bool = False,
260257
fragments_json: str = "",
261-
out_signed_fragment: bool = False,
262258
):
263259
if container_definitions is None:
264260
container_definitions = []
@@ -365,40 +361,24 @@ def acifragmentgen_confcom(
365361

366362
fragment_text = policy.generate_fragment(namespace, svn, output_type, omit_id=omit_id)
367363

368-
if output_type != security_policy.OutputType.DEFAULT and not no_print and not out_signed_fragment:
364+
if output_type != security_policy.OutputType.DEFAULT and not no_print:
369365
print(fragment_text)
370366

371367
# take ".rego" off the end of the filename if it's there, it'll get added back later
372368
output_filename = output_filename.replace(".rego", "")
373369
filename = f"{output_filename or namespace}.rego"
374-
375-
if out_signed_fragment:
376-
filename = os.path.join(tempfile.gettempdir(), filename)
377-
378370
os_util.write_str_to_file(filename, fragment_text)
379371

380372
if key:
381373
cose_proxy = CoseSignToolProxy()
382374
iss = cose_proxy.create_issuer(chain)
383375
out_path = filename + ".cose"
384376

385-
if out_signed_fragment:
386-
out_path = os.path.join(tempfile.gettempdir(), os.path.basename(out_path))
387-
388377
cose_proxy.cose_sign(filename, key, chain, feed, iss, algo, out_path)
389-
390-
# Preserve default behaviour established since version 1.1.0 of attaching
391-
# the fragment to the first image specified in input
392-
# (or --image-target if specified)
393-
if upload_fragment:
394-
oras_proxy.attach_fragment_to_image(
395-
image_name=image_target or policy_images[0].containerImage,
396-
filename=out_path,
397-
)
398-
399-
if out_signed_fragment:
400-
with open(out_path, "rb") as f:
401-
sys.stdout.buffer.write(f.read())
378+
if upload_fragment and image_target:
379+
oras_proxy.attach_fragment_to_image(image_target, out_path)
380+
elif upload_fragment:
381+
oras_proxy.push_fragment_to_registry(feed, out_path)
402382

403383

404384
def katapolicygen_confcom(
@@ -532,23 +512,3 @@ def get_fragment_output_type(outraw):
532512
if outraw:
533513
output_type = security_policy.OutputType.RAW
534514
return output_type
535-
536-
537-
def fragment_attach(
538-
signed_fragment: BinaryIO,
539-
manifest_tag: str,
540-
) -> None:
541-
_fragment_attach(
542-
signed_fragment=signed_fragment,
543-
manifest_tag=manifest_tag
544-
)
545-
546-
547-
def fragment_push(
548-
signed_fragment: BinaryIO,
549-
manifest_tag: str,
550-
) -> None:
551-
_fragment_push(
552-
signed_fragment=signed_fragment,
553-
manifest_tag=manifest_tag
554-
)

0 commit comments

Comments
 (0)