Skip to content

Commit

Permalink
Use randomly generated delimiter for multiline env variables
Browse files Browse the repository at this point in the history
The previous discussion in #6 finally has a proper answer, this updates it to follow `@actions/core`: https://github.com/actions/toolkit/blob/b36e70495fbee083eb20f600eafa9091d832577d/packages/core/src/file-command.ts#L27-L47
  • Loading branch information
SaschaMann committed Nov 5, 2022
1 parent 29275f5 commit 99fb387
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
1 change: 1 addition & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ version = "0.1.4"
[deps]
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"

[compat]
JSON = "0.21"
Expand Down
18 changes: 18 additions & 0 deletions THIRD_PARTY_NOTICE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Third Party Notices and Information

Parts of this software have been derived from other open source software.
Find their full licence information below.

- [`@actions/core`](https://github.com/actions/toolkit/tree/main/packages/core)

## [`@actions/core`](https://github.com/actions/toolkit/tree/main/packages/core)

> The MIT License (MIT)
>
>Copyright 2019 GitHub
>
> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
>
> The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
>
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
12 changes: 8 additions & 4 deletions src/GitHubActions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ using Logging: Logging, AbstractLogger, Debug, Info, Warn, Error

using JSON: json

using UUIDs

const CMD_MARKER = "::"

"""
Expand Down Expand Up @@ -188,10 +190,12 @@ Set environment variable `k` to value `v`.
function set_env(k, v)
val = cmd_value(v)
ENV[k] = val
delimiter = "EOF"
while occursin(delimiter, val)
delimiter *= "EOF"
end
delimiter = uuid4()

# Safety precaution in case UUID generation is exploitable
!occursin(string(delimiter), val) || (set_failed("value of environment variable must not contain the delimiter $delimiter"); exit())
!occursin(string(delimiter), k) || (set_failed("name of environment variable must not contain the delimiter $delimiter"); exit())

add_to_file("GITHUB_ENV", join(["$k<<$delimiter", val, delimiter], "\n"))
end

Expand Down

0 comments on commit 99fb387

Please sign in to comment.