Skip to content

Commit ac9d765

Browse files
author
awstools
committed
feat(client-codeartifact): This release introduces Package Origin Controls, a mechanism used to counteract Dependency Confusion attacks. Adds two new APIs, PutPackageOriginConfiguration and DescribePackage, and updates the ListPackage, DescribePackageVersion and ListPackageVersion APIs in support of the feature.
1 parent 4881c96 commit ac9d765

File tree

10 files changed

+1586
-230
lines changed

10 files changed

+1586
-230
lines changed

clients/client-codeartifact/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,11 @@ contains information about the requested domain.</p>
149149
</li>
150150
<li>
151151
<p>
152+
<code>DescribePackage</code>: Returns a <a href="https://docs.aws.amazon.com/codeartifact/latest/APIReference/API_PackageDescription.html">PackageDescription</a>
153+
object that contains details about a package. </p>
154+
</li>
155+
<li>
156+
<p>
152157
<code>DescribePackageVersion</code>: Returns a <a href="https://docs.aws.amazon.com/codeartifact/latest/APIReference/API_PackageVersionDescription.html">PackageVersionDescription</a>
153158
object that contains details about a package version. </p>
154159
</li>
@@ -256,6 +261,11 @@ package in a repository.</p>
256261
</li>
257262
<li>
258263
<p>
264+
<code>PutPackageOriginConfiguration</code>: Sets the package origin configuration for a package, which determine
265+
how new versions of the package can be added to a specific repository.</p>
266+
</li>
267+
<li>
268+
<p>
259269
<code>PutRepositoryPermissionsPolicy</code>: Sets the resource policy on a repository
260270
that specifies permissions to access it. </p>
261271
</li>

clients/client-codeartifact/src/Codeartifact.ts

Lines changed: 97 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ import {
5252
DescribeDomainCommandInput,
5353
DescribeDomainCommandOutput,
5454
} from "./commands/DescribeDomainCommand";
55+
import {
56+
DescribePackageCommand,
57+
DescribePackageCommandInput,
58+
DescribePackageCommandOutput,
59+
} from "./commands/DescribePackageCommand";
5560
import {
5661
DescribePackageVersionCommand,
5762
DescribePackageVersionCommandInput,
@@ -143,6 +148,11 @@ import {
143148
PutDomainPermissionsPolicyCommandInput,
144149
PutDomainPermissionsPolicyCommandOutput,
145150
} from "./commands/PutDomainPermissionsPolicyCommand";
151+
import {
152+
PutPackageOriginConfigurationCommand,
153+
PutPackageOriginConfigurationCommandInput,
154+
PutPackageOriginConfigurationCommandOutput,
155+
} from "./commands/PutPackageOriginConfigurationCommand";
146156
import {
147157
PutRepositoryPermissionsPolicyCommand,
148158
PutRepositoryPermissionsPolicyCommandInput,
@@ -306,6 +316,11 @@ import {
306316
* </li>
307317
* <li>
308318
* <p>
319+
* <code>DescribePackage</code>: Returns a <a href="https://docs.aws.amazon.com/codeartifact/latest/APIReference/API_PackageDescription.html">PackageDescription</a>
320+
* object that contains details about a package. </p>
321+
* </li>
322+
* <li>
323+
* <p>
309324
* <code>DescribePackageVersion</code>: Returns a <a href="https://docs.aws.amazon.com/codeartifact/latest/APIReference/API_PackageVersionDescription.html">PackageVersionDescription</a>
310325
* object that contains details about a package version. </p>
311326
* </li>
@@ -413,6 +428,11 @@ import {
413428
* </li>
414429
* <li>
415430
* <p>
431+
* <code>PutPackageOriginConfiguration</code>: Sets the package origin configuration for a package, which determine
432+
* how new versions of the package can be added to a specific repository.</p>
433+
* </li>
434+
* <li>
435+
* <p>
416436
* <code>PutRepositoryPermissionsPolicy</code>: Sets the resource policy on a repository
417437
* that specifies permissions to access it. </p>
418438
* </li>
@@ -788,6 +808,40 @@ export class Codeartifact extends CodeartifactClient {
788808
}
789809
}
790810

811+
/**
812+
* <p> Returns a
813+
* <a href="https://docs.aws.amazon.com/codeartifact/latest/APIReference/API_PackageDescription.html">PackageDescription</a>
814+
* object that contains information about the requested package.</p>
815+
*/
816+
public describePackage(
817+
args: DescribePackageCommandInput,
818+
options?: __HttpHandlerOptions
819+
): Promise<DescribePackageCommandOutput>;
820+
public describePackage(
821+
args: DescribePackageCommandInput,
822+
cb: (err: any, data?: DescribePackageCommandOutput) => void
823+
): void;
824+
public describePackage(
825+
args: DescribePackageCommandInput,
826+
options: __HttpHandlerOptions,
827+
cb: (err: any, data?: DescribePackageCommandOutput) => void
828+
): void;
829+
public describePackage(
830+
args: DescribePackageCommandInput,
831+
optionsOrCb?: __HttpHandlerOptions | ((err: any, data?: DescribePackageCommandOutput) => void),
832+
cb?: (err: any, data?: DescribePackageCommandOutput) => void
833+
): Promise<DescribePackageCommandOutput> | void {
834+
const command = new DescribePackageCommand(args);
835+
if (typeof optionsOrCb === "function") {
836+
this.send(command, optionsOrCb);
837+
} else if (typeof cb === "function") {
838+
if (typeof optionsOrCb !== "object") throw new Error(`Expect http options but get ${typeof optionsOrCb}`);
839+
this.send(command, optionsOrCb || {}, cb);
840+
} else {
841+
return this.send(command, optionsOrCb);
842+
}
843+
}
844+
791845
/**
792846
* <p>
793847
* Returns a
@@ -1069,7 +1123,9 @@ export class Codeartifact extends CodeartifactClient {
10691123

10701124
/**
10711125
* <p>
1072-
* Gets the readme file or descriptive text for a package version.
1126+
* Gets the readme file or descriptive text for a package version. For packages that do not contain a readme file, CodeArtifact
1127+
* extracts a description from a metadata file. For example, from the <code><description></code> element in the
1128+
* <code>pom.xml</code> file of a Maven package.
10731129
* </p>
10741130
* <p>
10751131
* The returned text might contain formatting. For example, it might contain formatting for Markdown or reStructuredText.
@@ -1511,6 +1567,46 @@ export class Codeartifact extends CodeartifactClient {
15111567
}
15121568
}
15131569

1570+
/**
1571+
* <p>Sets the package origin configuration for a package.</p>
1572+
* <p>The package origin configuration determines how new versions of a package can be added to a repository. You can allow or block direct
1573+
* publishing of new package versions, or ingestion and retaining of new package versions from an external connection or upstream source.
1574+
* For more information about package origin controls and configuration, see <a href="https://docs.aws.amazon.com/codeartifact/latest/ug/package-origin-controls.html">Editing package origin controls</a> in the <i>CodeArtifact User Guide</i>.</p>
1575+
* <p>
1576+
* <code>PutPackageOriginConfiguration</code> can be called on a package that doesn't yet exist in the repository. When called
1577+
* on a package that does not exist, a package is created in the repository with no versions and the requested restrictions are set on the package.
1578+
* This can be used to preemptively block ingesting or retaining any versions from external connections or upstream repositories, or to block
1579+
* publishing any versions of the package into the repository before connecting any package managers or publishers to the repository.</p>
1580+
*/
1581+
public putPackageOriginConfiguration(
1582+
args: PutPackageOriginConfigurationCommandInput,
1583+
options?: __HttpHandlerOptions
1584+
): Promise<PutPackageOriginConfigurationCommandOutput>;
1585+
public putPackageOriginConfiguration(
1586+
args: PutPackageOriginConfigurationCommandInput,
1587+
cb: (err: any, data?: PutPackageOriginConfigurationCommandOutput) => void
1588+
): void;
1589+
public putPackageOriginConfiguration(
1590+
args: PutPackageOriginConfigurationCommandInput,
1591+
options: __HttpHandlerOptions,
1592+
cb: (err: any, data?: PutPackageOriginConfigurationCommandOutput) => void
1593+
): void;
1594+
public putPackageOriginConfiguration(
1595+
args: PutPackageOriginConfigurationCommandInput,
1596+
optionsOrCb?: __HttpHandlerOptions | ((err: any, data?: PutPackageOriginConfigurationCommandOutput) => void),
1597+
cb?: (err: any, data?: PutPackageOriginConfigurationCommandOutput) => void
1598+
): Promise<PutPackageOriginConfigurationCommandOutput> | void {
1599+
const command = new PutPackageOriginConfigurationCommand(args);
1600+
if (typeof optionsOrCb === "function") {
1601+
this.send(command, optionsOrCb);
1602+
} else if (typeof cb === "function") {
1603+
if (typeof optionsOrCb !== "object") throw new Error(`Expect http options but get ${typeof optionsOrCb}`);
1604+
this.send(command, optionsOrCb || {}, cb);
1605+
} else {
1606+
return this.send(command, optionsOrCb);
1607+
}
1608+
}
1609+
15141610
/**
15151611
* <p>
15161612
* Sets the resource policy on a repository that specifies permissions to access it.

clients/client-codeartifact/src/CodeartifactClient.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ import {
7878
DeleteRepositoryPermissionsPolicyCommandOutput,
7979
} from "./commands/DeleteRepositoryPermissionsPolicyCommand";
8080
import { DescribeDomainCommandInput, DescribeDomainCommandOutput } from "./commands/DescribeDomainCommand";
81+
import { DescribePackageCommandInput, DescribePackageCommandOutput } from "./commands/DescribePackageCommand";
8182
import {
8283
DescribePackageVersionCommandInput,
8384
DescribePackageVersionCommandOutput,
@@ -142,6 +143,10 @@ import {
142143
PutDomainPermissionsPolicyCommandInput,
143144
PutDomainPermissionsPolicyCommandOutput,
144145
} from "./commands/PutDomainPermissionsPolicyCommand";
146+
import {
147+
PutPackageOriginConfigurationCommandInput,
148+
PutPackageOriginConfigurationCommandOutput,
149+
} from "./commands/PutPackageOriginConfigurationCommand";
145150
import {
146151
PutRepositoryPermissionsPolicyCommandInput,
147152
PutRepositoryPermissionsPolicyCommandOutput,
@@ -166,6 +171,7 @@ export type ServiceInputTypes =
166171
| DeleteRepositoryCommandInput
167172
| DeleteRepositoryPermissionsPolicyCommandInput
168173
| DescribeDomainCommandInput
174+
| DescribePackageCommandInput
169175
| DescribePackageVersionCommandInput
170176
| DescribeRepositoryCommandInput
171177
| DisassociateExternalConnectionCommandInput
@@ -185,6 +191,7 @@ export type ServiceInputTypes =
185191
| ListRepositoriesInDomainCommandInput
186192
| ListTagsForResourceCommandInput
187193
| PutDomainPermissionsPolicyCommandInput
194+
| PutPackageOriginConfigurationCommandInput
188195
| PutRepositoryPermissionsPolicyCommandInput
189196
| TagResourceCommandInput
190197
| UntagResourceCommandInput
@@ -202,6 +209,7 @@ export type ServiceOutputTypes =
202209
| DeleteRepositoryCommandOutput
203210
| DeleteRepositoryPermissionsPolicyCommandOutput
204211
| DescribeDomainCommandOutput
212+
| DescribePackageCommandOutput
205213
| DescribePackageVersionCommandOutput
206214
| DescribeRepositoryCommandOutput
207215
| DisassociateExternalConnectionCommandOutput
@@ -221,6 +229,7 @@ export type ServiceOutputTypes =
221229
| ListRepositoriesInDomainCommandOutput
222230
| ListTagsForResourceCommandOutput
223231
| PutDomainPermissionsPolicyCommandOutput
232+
| PutPackageOriginConfigurationCommandOutput
224233
| PutRepositoryPermissionsPolicyCommandOutput
225234
| TagResourceCommandOutput
226235
| UntagResourceCommandOutput
@@ -521,6 +530,11 @@ export interface CodeartifactClientResolvedConfig extends CodeartifactClientReso
521530
* </li>
522531
* <li>
523532
* <p>
533+
* <code>DescribePackage</code>: Returns a <a href="https://docs.aws.amazon.com/codeartifact/latest/APIReference/API_PackageDescription.html">PackageDescription</a>
534+
* object that contains details about a package. </p>
535+
* </li>
536+
* <li>
537+
* <p>
524538
* <code>DescribePackageVersion</code>: Returns a <a href="https://docs.aws.amazon.com/codeartifact/latest/APIReference/API_PackageVersionDescription.html">PackageVersionDescription</a>
525539
* object that contains details about a package version. </p>
526540
* </li>
@@ -628,6 +642,11 @@ export interface CodeartifactClientResolvedConfig extends CodeartifactClientReso
628642
* </li>
629643
* <li>
630644
* <p>
645+
* <code>PutPackageOriginConfiguration</code>: Sets the package origin configuration for a package, which determine
646+
* how new versions of the package can be added to a specific repository.</p>
647+
* </li>
648+
* <li>
649+
* <p>
631650
* <code>PutRepositoryPermissionsPolicy</code>: Sets the resource policy on a repository
632651
* that specifies permissions to access it. </p>
633652
* </li>
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
// smithy-typescript generated code
2+
import { getSerdePlugin } from "@aws-sdk/middleware-serde";
3+
import { HttpRequest as __HttpRequest, HttpResponse as __HttpResponse } from "@aws-sdk/protocol-http";
4+
import { Command as $Command } from "@aws-sdk/smithy-client";
5+
import {
6+
FinalizeHandlerArguments,
7+
Handler,
8+
HandlerExecutionContext,
9+
HttpHandlerOptions as __HttpHandlerOptions,
10+
MetadataBearer as __MetadataBearer,
11+
MiddlewareStack,
12+
SerdeContext as __SerdeContext,
13+
} from "@aws-sdk/types";
14+
15+
import { CodeartifactClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../CodeartifactClient";
16+
import { DescribePackageRequest, DescribePackageResult } from "../models/models_0";
17+
import {
18+
deserializeAws_restJson1DescribePackageCommand,
19+
serializeAws_restJson1DescribePackageCommand,
20+
} from "../protocols/Aws_restJson1";
21+
22+
export interface DescribePackageCommandInput extends DescribePackageRequest {}
23+
export interface DescribePackageCommandOutput extends DescribePackageResult, __MetadataBearer {}
24+
25+
/**
26+
* <p> Returns a
27+
* <a href="https://docs.aws.amazon.com/codeartifact/latest/APIReference/API_PackageDescription.html">PackageDescription</a>
28+
* object that contains information about the requested package.</p>
29+
* @example
30+
* Use a bare-bones client and the command you need to make an API call.
31+
* ```javascript
32+
* import { CodeartifactClient, DescribePackageCommand } from "@aws-sdk/client-codeartifact"; // ES Modules import
33+
* // const { CodeartifactClient, DescribePackageCommand } = require("@aws-sdk/client-codeartifact"); // CommonJS import
34+
* const client = new CodeartifactClient(config);
35+
* const command = new DescribePackageCommand(input);
36+
* const response = await client.send(command);
37+
* ```
38+
*
39+
* @see {@link DescribePackageCommandInput} for command's `input` shape.
40+
* @see {@link DescribePackageCommandOutput} for command's `response` shape.
41+
* @see {@link CodeartifactClientResolvedConfig | config} for CodeartifactClient's `config` shape.
42+
*
43+
*/
44+
export class DescribePackageCommand extends $Command<
45+
DescribePackageCommandInput,
46+
DescribePackageCommandOutput,
47+
CodeartifactClientResolvedConfig
48+
> {
49+
// Start section: command_properties
50+
// End section: command_properties
51+
52+
constructor(readonly input: DescribePackageCommandInput) {
53+
// Start section: command_constructor
54+
super();
55+
// End section: command_constructor
56+
}
57+
58+
/**
59+
* @internal
60+
*/
61+
resolveMiddleware(
62+
clientStack: MiddlewareStack<ServiceInputTypes, ServiceOutputTypes>,
63+
configuration: CodeartifactClientResolvedConfig,
64+
options?: __HttpHandlerOptions
65+
): Handler<DescribePackageCommandInput, DescribePackageCommandOutput> {
66+
this.middlewareStack.use(getSerdePlugin(configuration, this.serialize, this.deserialize));
67+
68+
const stack = clientStack.concat(this.middlewareStack);
69+
70+
const { logger } = configuration;
71+
const clientName = "CodeartifactClient";
72+
const commandName = "DescribePackageCommand";
73+
const handlerExecutionContext: HandlerExecutionContext = {
74+
logger,
75+
clientName,
76+
commandName,
77+
inputFilterSensitiveLog: DescribePackageRequest.filterSensitiveLog,
78+
outputFilterSensitiveLog: DescribePackageResult.filterSensitiveLog,
79+
};
80+
const { requestHandler } = configuration;
81+
return stack.resolve(
82+
(request: FinalizeHandlerArguments<any>) =>
83+
requestHandler.handle(request.request as __HttpRequest, options || {}),
84+
handlerExecutionContext
85+
);
86+
}
87+
88+
private serialize(input: DescribePackageCommandInput, context: __SerdeContext): Promise<__HttpRequest> {
89+
return serializeAws_restJson1DescribePackageCommand(input, context);
90+
}
91+
92+
private deserialize(output: __HttpResponse, context: __SerdeContext): Promise<DescribePackageCommandOutput> {
93+
return deserializeAws_restJson1DescribePackageCommand(output, context);
94+
}
95+
96+
// Start section: command_body_extra
97+
// End section: command_body_extra
98+
}

clients/client-codeartifact/src/commands/GetPackageVersionReadmeCommand.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ export interface GetPackageVersionReadmeCommandOutput extends GetPackageVersionR
2424

2525
/**
2626
* <p>
27-
* Gets the readme file or descriptive text for a package version.
27+
* Gets the readme file or descriptive text for a package version. For packages that do not contain a readme file, CodeArtifact
28+
* extracts a description from a metadata file. For example, from the <code><description></code> element in the
29+
* <code>pom.xml</code> file of a Maven package.
2830
* </p>
2931
* <p>
3032
* The returned text might contain formatting. For example, it might contain formatting for Markdown or reStructuredText.

0 commit comments

Comments
 (0)