Add ValidVolumes config #226

Merged
wolfogre merged 11 commits from Zettat123/act_runner:valid-volumes-config into main 2023-06-16 06:07:50 +00:00
Member

Follow gitea/act#60, gitea/act#64

This PR adds the valid_volumes configuration. valid_volumes is a sequence containing the volumes (including bind mounts) that can be mounted to the container. By default, valid_volumes is empty, which means that no volumes can be mounted. Users can specify multiple valid volumes and glob is supported.

All volumes will be allowed when using exec to run workflows locally.

Follow https://gitea.com/gitea/act/pulls/60, https://gitea.com/gitea/act/pulls/64 This PR adds the `valid_volumes` configuration. `valid_volumes` is a sequence containing the volumes (including bind mounts) that can be mounted to the container. By default, `valid_volumes` is empty, which means that no volumes can be mounted. Users can specify multiple valid volumes and [glob](https://github.com/gobwas/glob) is supported. All volumes will be allowed when using `exec` to run workflows locally.
Zettat123 added 1 commit 2023-06-04 13:03:48 +00:00
add ValidVolumes Config
Some checks failed
checks / check and test (pull_request) Failing after 49s
8c40ed2098
Zettat123 added 1 commit 2023-06-06 05:15:37 +00:00
Merge branch 'main' into valid-volumes-config
All checks were successful
checks / check and test (pull_request) Successful in 42s
37ce48e3ab
Zettat123 added 1 commit 2023-06-06 05:50:55 +00:00
update comment
All checks were successful
checks / check and test (pull_request) Successful in 40s
a895e8ebd2
Zettat123 changed title from WIP: Add `ValidVolumes` config to Add `ValidVolumes` config 2023-06-06 06:00:49 +00:00
wolfogre reviewed 2023-06-06 06:57:19 +00:00
@ -56,0 +56,4 @@
# Volumes (including bind mounts) can be mounted to containers.
# This is a sequence. If the sequence is empty, any volume can be mounted.
# Used for `jobs.<job_id>.container.volumes` or `jobs.<job_id>.services.<service_id>.volumes`
valid_volumes:
Owner

Maybe:

-  valid_volumes:
+  valid_volumes: []

And show some examples.

Maybe: ```diff - valid_volumes: + valid_volumes: [] ``` And show some examples.
Author
Member

fixed in fc5c076c1b

fixed in fc5c076c1bfc7229dd5bcf4106a3bb5879aca851
Zettat123 marked this conversation as resolved
Zettat123 added 1 commit 2023-06-06 07:10:40 +00:00
improve valid_volumes instruction
All checks were successful
checks / check and test (pull_request) Successful in 40s
fc5c076c1b
wolfogre approved these changes 2023-06-06 08:18:30 +00:00
Dismissed
lunny approved these changes 2023-06-08 03:55:56 +00:00
Dismissed
Owner

But how do you deny any volumes to be mounted?

But how do you deny any volumes to be mounted?
lunny dismissed lunny’s review 2023-06-08 03:56:56 +00:00
Reason:

see my comment

wolfogre dismissed wolfogre’s review 2023-06-08 04:33:13 +00:00
Author
Member

But how do you deny any volumes to be mounted?

For now, we can specify an invalid volume name to deny any volumes, like this

valid_volumes:
  - '!'

Since only alphanumeric characters and ._- are allowed in volume names, any volumes whose name matches ! cannot be created.

In order to solve this problem completely, maybe we need a new configuration, such as DisableMounts, if this configuration is true, any volumes or bind mounts will be disabled.

> But how do you deny any volumes to be mounted? ~~For now, we can specify an invalid volume name to deny any volumes, like this~~ ``` valid_volumes: - '!' ``` ~~Since only alphanumeric characters and `._-` are allowed in volume names, any volumes whose name matches `!` cannot be created.~~ ~~In order to solve this problem completely, maybe we need a new configuration, such as `DisableMounts`, if this configuration is true, any volumes or bind mounts will be disabled.~~
Zettat123 added 1 commit 2023-06-08 06:13:11 +00:00
add comment for denying any volumes
All checks were successful
checks / check and test (pull_request) Successful in 40s
a47e0841a6
wolfogre approved these changes 2023-06-09 01:51:04 +00:00
wolfogre added 1 commit 2023-06-09 01:51:18 +00:00
Merge branch 'main' into valid-volumes-config
All checks were successful
checks / check and test (pull_request) Successful in 41s
5502c5b9fb
Zettat123 changed title from Add `ValidVolumes` config to WIP: Add `ValidVolumes` config 2023-06-09 06:58:11 +00:00
Zettat123 added 1 commit 2023-06-09 10:25:59 +00:00
improve config instruction
All checks were successful
checks / check and test (pull_request) Successful in 57s
4ed768abac
Contributor

How to use it with act_runner exec? When I do something like act_runner exec --container-opts --volume=/file:/file:ro there is error [/file:/file:ro] is not a valid volume, will be ignored. nektos/act allows the same by default. Maybe it would be better to do the same?

How to use it with `act_runner exec`? When I do something like `act_runner exec --container-opts --volume=/file:/file:ro` there is error `[/file:/file:ro] is not a valid volume, will be ignored`. nektos/act allows the same by default. Maybe it would be better to do the same?
Contributor

But how do you deny any volumes to be mounted?

For now, we can specify an invalid volume name to deny any volumes, like this

valid_volumes:
  - '!'

Hmmm was the intention to allow by default ?

> > But how do you deny any volumes to be mounted? > > ~~For now, we can specify an invalid volume name to deny any volumes, like this~~ > ``` > valid_volumes: > - '!' > ``` Hmmm was the intention to allow by default ?
Author
Member

How to use it with act_runner exec? When I do something like act_runner exec --container-opts --volume=/file:/file:ro there is error [/file:/file:ro] is not a valid volume, will be ignored. nektos/act allows the same by default. Maybe it would be better to do the same?

Good catch. I think when using act_runner exec we should allow any volumes by default.

Hmmm was the intention to allow by default ?

In the latest commit (see 4ed768abac), the valid_volumes is empty by default so no data volumes are allowed except those listed in gitea/act#60

> How to use it with `act_runner exec`? When I do something like `act_runner exec --container-opts --volume=/file:/file:ro` there is error `[/file:/file:ro] is not a valid volume, will be ignored`. nektos/act allows the same by default. Maybe it would be better to do the same? Good catch. I think when using `act_runner exec` we should allow any volumes by default. > Hmmm was the intention to allow by default ? In the latest commit (see 4ed768abacbb9e5e5a97b03061b8c3218bd95113), the `valid_volumes` is empty by default so no data volumes are allowed except those listed in https://gitea.com/gitea/act/pulls/60
Zettat123 added 1 commit 2023-06-13 02:44:33 +00:00
fix exec
All checks were successful
checks / check and test (pull_request) Successful in 56s
50b18cb98e
Zettat123 added 1 commit 2023-06-16 05:34:08 +00:00
Merge branch 'main' into valid-volumes-config
All checks were successful
checks / check and test (pull_request) Successful in 54s
0a71026b2c
Zettat123 added 1 commit 2023-06-16 05:46:36 +00:00
upgrade act
All checks were successful
checks / check and test (pull_request) Successful in 1m17s
2a3586312d
Zettat123 changed title from WIP: Add `ValidVolumes` config to Add `ValidVolumes` config 2023-06-16 05:48:37 +00:00
Zettat123 added 1 commit 2023-06-16 06:00:39 +00:00
fix act version
All checks were successful
checks / check and test (pull_request) Successful in 1m18s
5c36400a43
wolfogre merged commit ec38401097 into main 2023-06-16 06:07:50 +00:00
Sign in to join this conversation.
No description provided.