Skip to content

Commit c6f8c77

Browse files
authored
Update to version 6.2.6 (#554)
1 parent 9375a0a commit c6f8c77

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1259
-396
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
# dependencies
1212
**/node_modules
13+
**/modules
1314

1415
# test assets
1516
**/coverage

CHANGELOG.md

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,44 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8-
## [6.2.5] - 2024-01-12
8+
## [6.2.6] - 2024-06-27
9+
10+
### Added
11+
- StackId tag to CloudFrontLoggingBucket and its bucket name as a CfnOutput [#529](https://github.com/aws-solutions/serverless-image-handler/issues/529)
12+
- Test case to verify UTF-8 support in object key [#320](https://github.com/aws-solutions/serverless-image-handler/pull/320)
13+
- Test cases to verify crop functionality [#459](https://github.com/aws-solutions/serverless-image-handler/pull/459)
14+
- VERSION.txt and build script change to auto-update local package versions
15+
- S3:bucket-name tag for defining which source bucket to use in thumbor style requests [#521](https://github.com/aws-solutions/serverless-image-handler/pull/521)
16+
- Ability to override whether an image should be animated [#456](https://github.com/aws-solutions/serverless-image-handler/issues/456)
17+
- Support for 8-bit depth AVIF image type inference [#360](https://github.com/aws-solutions/serverless-image-handler/issues/360)
18+
19+
### Changed
20+
- Decreased permissions allotted to CustomResource Lambda and ImageHandler Lambda
21+
- cdk update to 2.124.0
22+
- aws-solutions-constructs update to 2.51.0
23+
- SourceBucketsParameter to require explicit bucket names
24+
- Demo-ui dependency update
25+
- Demo-ui to be a package and manage script/stylesheet dependencies through NPM
26+
- Modified JPEG SOI marker parsing to only check first 2 bytes [#429]
27+
28+
### Security
29+
- Upgraded follow-redirects to v1.15.6 for vulnerability CVE-2024-28849
30+
- Upgraded braces to v3.0.3 for vulnerability CVE-2024-4068
31+
32+
### Removed
33+
- Unused CopyS3Assets custom resource
34+
35+
### Fixed
36+
- Some error messages indicating incorrect file types
37+
- Solution version and id not being passed to Backend Lambda
38+
- Thumbor-style URL matching being overly permissive
39+
40+
41+
## [6.2.5] - 2024-01-03
942

1043
### Fixed
1144

1245
- Ensure accurate image metadata when generating Amazon Rekognition compatible images [#374](https://github.com/aws-solutions/serverless-image-handler/issues/374)
13-
- Upgraded axios to v1.6.5 for vulnerability CVE-2023-26159
1446
- Exclude demo-ui-config from being deleted upon BucketDeployment update sync when updating to a new version
1547

1648
### Changed
@@ -20,6 +52,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2052
- typescript update to 5.3.3
2153
- GIF files without multiple pages are now treated as non-animated, allowing all filters to be used on them [#460](https://github.com/aws-solutions/serverless-image-handler/issues/460)
2254

55+
### Security
56+
57+
- Upgraded axios to v1.6.5 for vulnerability CVE-2023-26159
58+
2359
## [6.2.4] - 2023-12-06
2460

2561
### Changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ This solution collects anonymous operational metrics to help AWS improve the qua
105105
- [@Fjool](https://github.com/Fjool) for [#489](https://github.com/aws-solutions/serverless-image-handler/pull/489)
106106
- [@fvsnippets](https://github.com/fvsnippets) for [#373](https://github.com/aws-solutions/serverless-image-handler/pull/373), [#380](https://github.com/aws-solutions/serverless-image-handler/pull/380)
107107
- [@ccchapman](https://github.com/ccchapman) for [#490](https://github.com/aws-solutions/serverless-image-handler/pull/490)
108+
- [@bennet-esyoil][https://github.com/bennet-esyoil] for [#521](https://github.com/aws-solutions/serverless-image-handler/pull/521)
109+
- [@vaniyokk][https://github.com/vaniyokk] for [#511](https://github.com/aws-solutions/serverless-image-handler/pull/511)
108110

109111
# License
110112

VERSION.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
6.2.6

deployment/build-s3-dist.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ mkdir -p "$template_dist_dir"
3232
rm -rf "$build_dist_dir"
3333
mkdir -p "$build_dist_dir"
3434

35+
headline "[Init] Ensure package versions are updated"
36+
npm --prefix "$source_dir" run bump-version
37+
3538
headline "[Build] Synthesize cdk template and assets"
3639
cd "$cdk_source_dir"
3740
npm run clean:install

deployment/cdk-solution-helper/package-lock.json

Lines changed: 15 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

deployment/cdk-solution-helper/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
},
2323
"dependencies": {
2424
"adm-zip": "^0.5.10",
25-
"aws-cdk-lib": "^2.118.0"
25+
"aws-cdk-lib": "^2.124.0"
2626
},
2727
"overrides": {
2828
"semver": "7.5.4"

source/constructs/bin/constructs.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,13 @@ if (DIST_OUTPUT_BUCKET && SOLUTION_NAME && VERSION)
2020

2121
const app = new App();
2222
const solutionDisplayName = "Serverless Image Handler";
23-
const description = `(${app.node.tryGetContext("solutionId")}) - ${solutionDisplayName}. Version ${VERSION ?? app.node.tryGetContext("solutionVersion")}`;
23+
const solutionVersion = VERSION ?? app.node.tryGetContext("solutionVersion");
24+
const description = `(${app.node.tryGetContext("solutionId")}) - ${solutionDisplayName}. Version ${solutionVersion}`;
2425
// eslint-disable-next-line no-new
2526
new ServerlessImageHandlerStack(app, "ServerlessImageHandlerStack", {
26-
synthesizer: synthesizer,
27-
description: description,
27+
synthesizer,
28+
description,
2829
solutionId: app.node.tryGetContext("solutionId"),
29-
solutionVersion: app.node.tryGetContext("solutionVersion"),
30+
solutionVersion,
3031
solutionName: app.node.tryGetContext("solutionName"),
3132
});

source/constructs/cdk.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"app": "npx ts-node --prefer-ts-exts bin/constructs.ts",
33
"context": {
44
"solutionId": "SO0023",
5-
"solutionVersion": "custom-v6.2.5",
5+
"solutionVersion": "custom-v6.2.6",
66
"solutionName": "serverless-image-handler"
77
}
88
}

source/constructs/lib/back-end/back-end-construct.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,13 @@ import * as api from "aws-cdk-lib/aws-apigateway";
3131

3232
export interface BackEndProps extends SolutionConstructProps {
3333
readonly solutionVersion: string;
34+
readonly solutionId: string;
3435
readonly solutionName: string;
3536
readonly secretsManagerPolicy: Policy;
3637
readonly logsBucket: IBucket;
3738
readonly uuid: string;
3839
readonly cloudFrontPriceClass: string;
40+
readonly createSourceBucketsResource: (key?: string) => string[];
3941
}
4042

4143
export class BackEnd extends Construct {
@@ -64,15 +66,16 @@ export class BackEnd extends Construct {
6466
],
6567
}),
6668
new PolicyStatement({
67-
actions: ["s3:GetObject", "s3:PutObject", "s3:ListBucket"],
68-
resources: [
69-
Stack.of(this).formatArn({
70-
service: "s3",
71-
resource: "*",
72-
region: "",
73-
account: "",
74-
}),
75-
],
69+
actions: ["s3:GetObject"],
70+
resources: props.createSourceBucketsResource("/*"),
71+
}),
72+
new PolicyStatement({
73+
actions: ["s3:ListBucket"],
74+
resources: props.createSourceBucketsResource(),
75+
}),
76+
new PolicyStatement({
77+
actions: ["s3:GetObject"],
78+
resources: [`arn:aws:s3:::${props.fallbackImageS3Bucket}/${props.fallbackImageS3KeyBucket}`],
7679
}),
7780
new PolicyStatement({
7881
actions: ["rekognition:DetectFaces", "rekognition:DetectModerationLabels"],
@@ -106,6 +109,8 @@ export class BackEnd extends Construct {
106109
ENABLE_DEFAULT_FALLBACK_IMAGE: props.enableDefaultFallbackImage,
107110
DEFAULT_FALLBACK_IMAGE_BUCKET: props.fallbackImageS3Bucket,
108111
DEFAULT_FALLBACK_IMAGE_KEY: props.fallbackImageS3KeyBucket,
112+
SOLUTION_VERSION: props.solutionVersion,
113+
SOLUTION_ID: props.solutionId,
109114
},
110115
bundling: {
111116
externalModules: ["sharp"],

source/constructs/lib/common-resources/custom-resources/custom-resource-construct.ts

Lines changed: 49 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ import { Function as LambdaFunction, Runtime } from "aws-cdk-lib/aws-lambda";
77
import { NodejsFunction } from "aws-cdk-lib/aws-lambda-nodejs";
88
import { Bucket, IBucket } from "aws-cdk-lib/aws-s3";
99
import { BucketDeployment, Source as S3Source } from "aws-cdk-lib/aws-s3-deployment";
10-
import { ArnFormat, Aspects, Aws, CfnCondition, CfnResource, CustomResource, Duration, Lazy, Stack } from "aws-cdk-lib";
10+
import { ArnFormat, Aspects, Aws, CfnCondition, CfnResource, CustomResource, Duration, Fn, Lazy, Stack } from "aws-cdk-lib";
1111
import { Construct } from "constructs";
12-
import { addCfnSuppressRules } from "../../../utils/utils";
12+
import { addCfnCondition, addCfnSuppressRules } from "../../../utils/utils";
1313

1414
import { SolutionConstructProps } from "../../types";
1515
import { CommonResourcesProps, Conditions } from "../common-resources-construct";
@@ -45,7 +45,6 @@ export interface SetupValidateSecretsManagerProps {
4545
}
4646

4747
export class CustomResourcesConstruct extends Construct {
48-
private readonly solutionVersion: string;
4948
private readonly conditions: Conditions;
5049
private readonly customResourceRole: Role;
5150
private readonly customResourceLambda: LambdaFunction;
@@ -54,7 +53,6 @@ export class CustomResourcesConstruct extends Construct {
5453
constructor(scope: Construct, id: string, props: CustomResourcesConstructProps) {
5554
super(scope, id);
5655

57-
this.solutionVersion = props.solutionVersion;
5856
this.conditions = props.conditions;
5957

6058
this.customResourceRole = new Role(this, "CustomResourceRole", {
@@ -75,16 +73,26 @@ export class CustomResourcesConstruct extends Construct {
7573
}),
7674
],
7775
}),
76+
new PolicyStatement({
77+
actions: ['s3:ListBucket'],
78+
resources: this.createSourceBucketsResource()
79+
}),
80+
new PolicyStatement({
81+
actions: [
82+
"s3:GetObject",
83+
],
84+
resources: [
85+
`arn:aws:s3:::${props.fallbackImageS3Bucket}/${props.fallbackImageS3KeyBucket}`,
86+
],
87+
}),
7888
new PolicyStatement({
7989
actions: [
8090
"s3:putBucketAcl",
8191
"s3:putEncryptionConfiguration",
8292
"s3:putBucketPolicy",
8393
"s3:CreateBucket",
84-
"s3:GetObject",
85-
"s3:PutObject",
86-
"s3:ListBucket",
8794
"s3:PutBucketOwnershipControls",
95+
"s3:PutBucketTagging"
8896
],
8997
resources: [
9098
Stack.of(this).formatArn({
@@ -142,6 +150,21 @@ export class CustomResourcesConstruct extends Construct {
142150
this.uuid = customResourceUuid.getAttString("UUID");
143151
}
144152

153+
public setupWebsiteHostingBucketPolicy(websiteHostingBucket: IBucket) {
154+
const websiteHostingBucketPolicy = new Policy(this, "WebsiteHostingBucketPolicy", {
155+
document: new PolicyDocument({
156+
statements: [
157+
new PolicyStatement({
158+
actions: ["s3:GetObject", "s3:PutObject",],
159+
resources: [websiteHostingBucket.bucketArn + "/*"],
160+
}),
161+
],
162+
}),
163+
roles: [this.customResourceRole],
164+
})
165+
addCfnCondition(websiteHostingBucketPolicy, this.conditions.deployUICondition);
166+
};
167+
145168
public setupAnonymousMetric(props: AnonymousMetricCustomResourceProps) {
146169
this.createCustomResource("CustomResourceAnonymousMetric", this.customResourceLambda, {
147170
CustomAction: "sendMetric",
@@ -181,7 +204,9 @@ export class CustomResourcesConstruct extends Construct {
181204
// Stage static assets for the front-end from the local
182205
/* eslint-disable no-new */
183206
const bucketDeployment = new BucketDeployment(this, "DeployWebsite", {
184-
sources: [S3Source.asset(path.join(__dirname, "../../../../demo-ui"))],
207+
sources: [
208+
S3Source.asset(path.join(__dirname, "../../../../demo-ui"), { exclude: ["node_modules/*"] }),
209+
],
185210
destinationBucket: props.hostingBucket,
186211
exclude: ["demo-ui-config.js"],
187212
});
@@ -235,6 +260,22 @@ export class CustomResourcesConstruct extends Construct {
235260
return optInRegionAccessLogBucket;
236261
}
237262

263+
public createSourceBucketsResource(resourceName: string = "") {
264+
return Fn.split(
265+
',',
266+
Fn.sub(
267+
`arn:aws:s3:::\${rest}${resourceName}`,
268+
269+
{
270+
rest: Fn.join(
271+
`${resourceName},arn:aws:s3:::`,
272+
Fn.split(",", Fn.join("", Fn.split(" ", Fn.ref('SourceBucketsParameter'))))
273+
),
274+
},
275+
),
276+
)
277+
}
278+
238279
private createCustomResource(
239280
id: string,
240281
customResourceFunction: LambdaFunction,

0 commit comments

Comments
 (0)