cloud-gov / s3-simple-resource

Concourse CI Resource for uploading files to S3
https://hub.docker.com/r/18fgsa/s3-resource-simple/
Other
30 stars 74 forks source link

General best-practices cleanup #51

Open charles-dyfis-net opened 1 year ago

charles-dyfis-net commented 1 year ago

Changes proposed in this pull request:

Security considerations

Because we deliberately do not modify the behavior described in cloud-gov/s3-resource-simple#50, the preexisting opportunity for shell injection via $options remains intact. However, we do narrow the code to only be evaling $options, so it's no longer possible to perform shell injection via $bucket or $path.

In every other respect, this PR works to reduce runtime ambiguity, and thus to also reduce attack surface.

charles-dyfis-net commented 1 year ago

BTW, one thing that may be notable in the recently added commit (returning to a separate jq call per variable) is the change from echo to printf. For background on that, see the excellent answer by Stéphane Chazelas on Why is printf better than echo?, or the APPLICATION USAGE and RATIONALE sections of the POSIX standard for echo.

If we were specifying a specific shell (like bash), making assumptions about echo behavior would be slightly justifiable (though only slightly: even with bash, configuration parameters like xpg_echo modifying behaviors in the cases the standard describes as ambiguous can be set at compile time, or via environment variables at runtime, or via explicit runtime commands); but if we're using /bin/sh, best to avoid cases the POSIX sh standard describes as ambiguous altogether.

markdboyd commented 1 year ago

Approved. Thanks @charles-dyfis-net for the contribution!