File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -110,8 +110,10 @@ bot.interaction_create do |event|
110110 event . defer ( ephemeral : false )
111111
112112 begin
113+ user_id = event . interaction . user . id
113114 command = build_command_from_event ( event . interaction . data )
114- SemanticLogger [ 'DiscordBot' ] . info ( 'Executing command' , command : command )
115+ SemanticLogger [ 'DiscordBot' ] . info ( 'Executing command' , command : command , user_id : user_id )
116+ ENV [ 'DISCORD_USER_ID' ] = user_id . to_s
115117 result = Pyxis ::Cli . start ( command , { debug : true } )
116118 color = '#4caf50'
117119 rescue Pyxis ::MessageError => e
@@ -120,6 +122,8 @@ bot.interaction_create do |event|
120122 rescue Thor ::Error , Pyxis ::Error => e
121123 result = "#{ e . class } \n #{ e . message } "
122124 color = '#f44336'
125+ ensure
126+ ENV . delete ( 'DISCORD_USER_ID' )
123127 end
124128
125129 event . edit_response ( embeds : [ Discordrb ::Webhooks ::Embed . new ( description : result , color : color ) ] )
Original file line number Diff line number Diff line change 1+ users :
2+ - github : Taucher2003
3+ gitlab : Taucher2003
4+ discord : " 444889694002741249"
5+
6+ - github : nicosammito
7+ gitlab : nicosammito
8+ discord : " 456437986238791701"
9+
10+ - github : raphael-goetz
11+ gitlab : raphael.goetz.7
12+ discord : " 329279009298841600"
13+
14+ - github : Knerio
15+ gitlab : knerio
16+ discord : " 639416958923702292"
17+
18+ - github : mvriu5
19+ discord : " 388405725929406472"
20+
21+ - github : 1chroniks
22+ discord : " 572808505304809502"
23+
24+ - github : Nicuschgifthub
25+ discord : " 380808844093292555"
26+
27+ - github : code0-release-tools[bot]
28+ gitlab : code0-release-tools
29+ discord : " 1465083247296905299"
Original file line number Diff line number Diff line change @@ -26,6 +26,8 @@ def info
2626 method_option :sculptor_sha , desc : 'Commit SHA of sculptor to build' , type : :string
2727 method_option :taurus_sha , desc : 'Commit SHA of taurus to build' , type : :string
2828 def build
29+ assert_executed_by_known_team_member!
30+
2931 version_overrides = {
3032 aquila : options [ :aquila_sha ] ,
3133 draco : options [ :draco_sha ] ,
Original file line number Diff line number Diff line change @@ -13,5 +13,28 @@ def assert_executed_by_schedule!
1313
1414 raise PermissionError , 'This operation can only be run by a pipeline schedule'
1515 end
16+
17+ def assert_executed_by_known_team_member!
18+ return unless checks_active?
19+ return unless find_current_user . nil?
20+
21+ raise PermissionError , 'This operation can only be run by a known team member'
22+ end
23+
24+ def find_current_user
25+ if ENV [ 'GITLAB_USER_LOGIN' ]
26+ users . find { |user | user [ 'gitlab' ] == ENV [ 'GITLAB_USER_LOGIN' ] }
27+ elsif ENV [ 'DISCORD_USER_ID' ]
28+ users . find { |user | user [ 'discord' ] == ENV [ 'DISCORD_USER_ID' ] }
29+ else
30+ raise PermissionError , 'Missing data for permission checks'
31+ end
32+ end
33+
34+ private
35+
36+ def users
37+ YAML . safe_load_file ( File . absolute_path ( File . join ( __FILE__ , '../../../config/users.yml' ) ) ) [ 'users' ]
38+ end
1639 end
1740end
You can’t perform that action at this time.
0 commit comments