Skip to content

Move to smaller base image#20

Merged
Greg Tyler (gregtyler) merged 1 commit intomainfrom
VEGA-1215-update-antivirus-base-image
Mar 3, 2022
Merged

Move to smaller base image#20
Greg Tyler (gregtyler) merged 1 commit intomainfrom
VEGA-1215-update-antivirus-base-image

Conversation

@gregtyler
Copy link
Copy Markdown
Contributor

@gregtyler Greg Tyler (gregtyler) commented Mar 1, 2022

Use alpine as a base image, and install clamav properly so that it's just available on PATH. This led to a few changes to how we call clamscan and freshclam.

Without lambci, we now need aws-lambda-rie to provide the Lambda runtime environment (i.e. the HTTP API). Because this is just needed for local dev, mount it rather than installing on the image directly.

aws-lambda-rie causes two restrictions:

  • The function name must be "function". There's a PR to make this configurable, but AWS don't seem keen
  • It can only handle one invokation at a time, so we can't upload the second test file (and therefore invoke the Lamdba) until the first is finished

#minor

@codecov-commenter
Copy link
Copy Markdown

Codecov Comments Bot (codecov-commenter) commented Mar 1, 2022

Codecov Report

Merging #20 (21b879f) into main (f760245) will increase coverage by 0.28%.
The diff coverage is 66.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #20      +/-   ##
==========================================
+ Coverage   55.12%   55.41%   +0.28%     
==========================================
  Files           4        4              
  Lines         156      157       +1     
==========================================
+ Hits           86       87       +1     
  Misses         58       58              
  Partials       12       12              
Impacted Files Coverage Δ
cmd/opg-s3-antivirus-update/freshclam.go 0.00% <0.00%> (ø)
cmd/opg-s3-antivirus/scanner.go 0.00% <0.00%> (ø)
cmd/opg-s3-antivirus-update/main.go 42.85% <100.00%> (+1.03%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f760245...21b879f. Read the comment docs.

@gregtyler Greg Tyler (gregtyler) force-pushed the VEGA-1215-update-antivirus-base-image branch 3 times, most recently from bf159c2 to 21b879f Compare March 2, 2022 12:23
Use alpine as a base image, and install clamav properly so that it's just available on PATH. This led to a few changes to how we call `clamscan` and `freshclam`.

Without lambci, we now need `aws-lambda-rie` to provide the Lambda runtime environment (i.e. the HTTP API). Because this is just needed for local dev, mount it rather than installing on the image directly.

`aws-lambda-rie` causes two restrictions:
- The function name must be "function". There's [a PR to make this configurable](aws/aws-lambda-runtime-interface-emulator#46), but AWS don't seem keen
- It can only handle one invokation at a time, so we can't upload the second test file (and therefore invoke the Lamdba) until the first is finished

#minor
@gregtyler Greg Tyler (gregtyler) force-pushed the VEGA-1215-update-antivirus-base-image branch from 21b879f to 560bd6d Compare March 3, 2022 10:51
@gregtyler Greg Tyler (gregtyler) marked this pull request as ready for review March 3, 2022 10:51

func (c *Freshclam) Update() error {
cmd := exec.Command("./bin/freshclam")
cmd := exec.Command("freshclam", "--config-file=/etc/freshclam.conf")
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

For some reason the config file needs to be specified now, even though it's the default location. No harm in being specific though I guess 🤷🏽

Bucket: aws.String(l.bucket),
Key: aws.String(key),
Body: file,
ServerSideEncryption: aws.String("AES256"),
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is required by our S3 policy

COPY --from=build-clamav /usr/lib64/libpcre* /var/task/lib/
COPY --from=build-clamav /usr/lib64/libprelude* /var/task/lib/
COPY --from=build-clamav /usr/lib64/libtasn1* /var/task/lib/
RUN mkdir -p /tmp/clamav && chown -R clamav:clamav /tmp/clamav
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

/tmp is overwritten by Lambda in production but this is necessary locally, effectively emulating that behaviour

@gregtyler Greg Tyler (gregtyler) merged commit 12ed260 into main Mar 3, 2022
@gregtyler Greg Tyler (gregtyler) deleted the VEGA-1215-update-antivirus-base-image branch March 3, 2022 11:27
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