forked from gate-sso/gate-wireguard
-
Notifications
You must be signed in to change notification settings - Fork 0
Feat/vpn interface #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
NamSupawan
wants to merge
131
commits into
main
Choose a base branch
from
feat/vpn_interface
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 114 commits
Commits
Show all changes
131 commits
Select commit
Hold shift + click to select a range
e15d8ab
ui
NamSupawan 45b09fb
vpn
NamSupawan 419670f
template
NamSupawan 85a18af
wg
NamSupawan 5cb4312
vpn
NamSupawan 139eeb8
vpn
NamSupawan b67b885
vpn
NamSupawan 6bd89bc
vpn
NamSupawan d6a23a8
redirect
NamSupawan ccda009
btn
NamSupawan 17fe598
vpn
NamSupawan 0abb10c
btn
NamSupawan 3ba48aa
wg
NamSupawan 398d35c
fix error
NamSupawan c0daa11
fix error
NamSupawan 58bbd9a
param
NamSupawan 106a8e2
vpn
NamSupawan 117750e
vpn users
NamSupawan 3c1a54a
vpn users
NamSupawan 756c879
vpn users-error
NamSupawan 8aadf48
fix error
NamSupawan 0200d14
vpnddd
NamSupawan d224200
method
NamSupawan d5e0e68
fix
NamSupawan 6ad2488
open
NamSupawan d43a413
open
NamSupawan fd9ddbf
open
NamSupawan 29b32f2
open
NamSupawan 04ba672
open
NamSupawan 1be8dea
open
NamSupawan 49e64d2
open
NamSupawan be1341d
open
NamSupawan d271308
rem
NamSupawan 3fc5cbf
open
NamSupawan 557b7fe
firewall
NamSupawan 6fcb2df
show
NamSupawan 13a2c66
firewall
NamSupawan 4171444
show
NamSupawan 4fe5789
firewall
NamSupawan 14b38a7
firewall
NamSupawan adb558f
firewall
NamSupawan e7d4621
firewall
NamSupawan 2f68573
firewall
NamSupawan a9a6f44
firewall_params
NamSupawan c75325e
firewall_params
NamSupawan e560124
firewall_params
NamSupawan fefaad4
fix error
NamSupawan c118881
fix error
NamSupawan b7f6ef5
fix error
NamSupawan 8ef73de
fix error
NamSupawan 9d73f20
fix error
NamSupawan f05883d
fix error
NamSupawan d610bf3
fix error
NamSupawan 99db980
fix error
NamSupawan 6b4c7a9
fix error
NamSupawan 6dab87c
fix error
NamSupawan d57ad56
fix error
NamSupawan b9d0920
fix error
NamSupawan 5f0e25d
fix error
NamSupawan 27905e0
fix error
NamSupawan 409c8fe
fix error
NamSupawan 7496f9e
fix error
NamSupawan ee79cbb
fix error
NamSupawan 4b88825
fix error
NamSupawan 5b12384
fix error
NamSupawan 08297f5
fix error
NamSupawan c4bc830
fix error
NamSupawan 871b5f3
fix error
NamSupawan 8312bb7
fix error
NamSupawan e042bc8
html
NamSupawan e409a58
html
NamSupawan 27f9f1a
html
NamSupawan a18f390
html
NamSupawan 92ffba4
htmld
NamSupawan cfea219
firewall
NamSupawan 6809887
url path
NamSupawan 9165ec9
url path
NamSupawan 0f59315
url path
NamSupawan aad34c1
url path
NamSupawan d4e287e
url path
NamSupawan 27e7d59
url path
NamSupawan 6e1dcb1
url path
NamSupawan cf5c7ce
url path
NamSupawan 8b5e5fe
url path
NamSupawan 5e431d2
url path
NamSupawan bc9552f
url path
NamSupawan 2a602ba
url path
NamSupawan 607d11b
url path
NamSupawan bb6669a
url path
NamSupawan cdea5af
url path
NamSupawan b7c7de1
url path
NamSupawan dbeaac0
url path
NamSupawan f7782b7
url path
NamSupawan 4fe4f15
url path
NamSupawan fcfe0a5
url path
NamSupawan c5728e3
url path
NamSupawan 2afe32e
url path
NamSupawan ea12a5f
url path
NamSupawan 6d72fe1
url path
NamSupawan 7967bb9
url path
NamSupawan 7082eba
url path
NamSupawan 1ff06fc
url path
NamSupawan 1a97433
url path
NamSupawan d70d5ea
url path
NamSupawan 9a765fe
url path
NamSupawan c5d264c
url path
NamSupawan 68b5bfc
url path
NamSupawan 207d888
url path
NamSupawan b2f965d
peer
NamSupawan 8394d82
peer
NamSupawan 8edbbf1
required field
NamSupawan e648988
ip Address
NamSupawan 268d6ca
ip Address
NamSupawan 74dc12e
ip Address
NamSupawan 8bd03e0
test
NamSupawan eea234b
config
NamSupawan a5d82c1
add
NamSupawan 486af41
1
NamSupawan dff208d
vpn devices
NamSupawan f93314a
vpn
NamSupawan 5493aea
userId
NamSupawan d1774e6
path
NamSupawan 0aa6aa6
devices
NamSupawan c0c7509
create
NamSupawan b713825
controller
NamSupawan 9420fb5
check
NamSupawan 6c4b307
routes
NamSupawan a9becb7
Prod-drift snapshot 2026-05-13: live state from product-wireguard-vpn
pachara-flow 5dac7db
Merge pull request #12 from flowaccount/prod-drift-2026-05
pachara-flow 0d53db4
Hot-reload WireGuard on peer changes, race-safe IP allocation (#11)
pachara-flow e5ccf3c
Fix wg syncconf failing on new signups (stderr poisoning + 0644 perms…
pachara-flow File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
|
|
||
|
|
||
| class FirewallsController < ApplicationController | ||
| before_action :require_login | ||
| # before_action :get_iptables_rules, only: %i[show edit update destroy] | ||
| # before_action :set_vpn_configuration, only: %i[ show update edit ] | ||
| layout 'admin' | ||
|
|
||
| def index | ||
| @firewall = Firewall.new | ||
| end | ||
|
|
||
| def rules | ||
| @iptables_output = get_iptables_rules | ||
| end | ||
|
|
||
| def new | ||
| @firewall = Firewall.new | ||
| end | ||
|
|
||
| # Handle form submission | ||
| def create | ||
| @firewall = Firewall.new(firewall_params) | ||
| #@firewall.name = @rule_name | ||
| if @firewall.name.blank? || @firewall.name.nil? || @firewall.ipAddress.nil? | ||
| render json: @firewall, status: :ok | ||
| else | ||
| name = @firewall.name | ||
| ip = @firewall.ipAddress | ||
| command = "sudo ipset add #{name} #{ip}" | ||
| output, status = Open3.capture2e(command) | ||
|
|
||
| if status.success? | ||
| Open3.capture2e("sudo iptables-save > /etc/iptables/rules.v4") | ||
| Open3.capture2e("sudo systemctl restart iptables") | ||
| flash[:notice] = "Add Allowed IP Address: #{@firewall.name}" | ||
| render plain: "Success Add Allowed IP", status: :ok | ||
| else | ||
| render :index, alert: "Failed to create WireGuard interface:\n#{output}" | ||
| end | ||
| end | ||
| end | ||
|
|
||
| def update_display_rules | ||
| rules_name = params[:rules_name] | ||
|
|
||
| if rules_name | ||
| @allowed_ips_output = get_allowed_ip_addresses(rules_name) | ||
| @firewall = Firewall.new | ||
| @firewall.name = rules_name | ||
| @rule_name = rules_name | ||
| # Handle active status logic here | ||
| render :index | ||
| else | ||
| # Handle inactive status logic here | ||
| render plain: "Failed to update firewall", status: :unprocessable_entity | ||
| end | ||
| end | ||
|
|
||
| private | ||
|
|
||
| def firewall_params | ||
| params.require(:firewall).permit(:name, :ipAddress) | ||
| end | ||
|
|
||
| def get_allowed_ip_addresses(name) | ||
| command = "sudo ipset list #{name} | awk 'NR > 7 { print $1 }'" | ||
|
|
||
| output, status = Open3.capture2e(command) | ||
|
|
||
| if status.success? | ||
| output # Return iptables output | ||
| else | ||
| "Error fetching iptables rules: #{stderr}" # Handle errors | ||
| end | ||
| end | ||
|
|
||
| def get_iptables_rules | ||
| command = "sudo iptables -L -n -v --line-number" | ||
|
|
||
| output, status = Open3.capture2e(command) | ||
|
|
||
| if status.success? | ||
| output # Return iptables output | ||
| else | ||
| "Error fetching iptables rules: #{stderr}" # Handle errors | ||
| end | ||
| end | ||
| end | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| # app/models/firewall.rb | ||
| class Firewall | ||
| include ActiveModel::Model | ||
| # model code | ||
| attr_accessor :name, :ipAddress | ||
|
|
||
|
|
||
| end | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,20 +1,28 @@ | ||
| <table class="table table-striped"> | ||
| <thead> | ||
| <tr> | ||
| <th>Row</th> | ||
| <th>Name</th> | ||
| <th>Email</th> | ||
| <th>Admin</th> | ||
| </tr> | ||
| </thead> | ||
| <tbody> | ||
| <% @users.each do |user| %> | ||
| <% @users.each_with_index do |user , index| %> | ||
| <tr> | ||
| <td><%= index+1 %></td> | ||
| <td><%= user.name %></td> | ||
| <td><%= user.email %></td> | ||
| <td> | ||
| <div class="form-check"> | ||
| <input class="form-check-input" type="checkbox" <%= 'checked' if user.admin? %> | ||
| <%= 'disabled' if current_user == user %>> | ||
|
|
||
| <%= form_with url: update_users_admin_path(user), method: :patch, remote: false do |form| %> | ||
| <%= form.check_box :active, { | ||
| onchange: 'this.form.submit();', | ||
| disabled: current_user == user, | ||
| checked: user.admin | ||
| } %> | ||
| <% end %> | ||
| </div> | ||
| </div> | ||
| </td> | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,14 @@ | |
| <div style="color: red">You will be required to re-configure all client devices on update, please be careful, | ||
| don't do it if you don't understand | ||
| </div> | ||
|
|
||
| <% @all_vpn_configuration.each do |config| %> | ||
| <tr> | ||
| <td><%= config.wg_ip_address %></td> | ||
| <td><%= config.wg_interface_name %></td> | ||
| </tr> | ||
| <% end %> | ||
|
|
||
| <hr> | ||
|
|
||
| <%= form_with model: @vpn_configuration, url: update_vpn_configuration_path(@vpn_configuration), local: true, html: { class: "form-horizontal" } do |form| %> | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| <h2>Rules Access</h2> | ||
|
|
||
| <%= turbo_frame_tag "status_display" do %> | ||
| <span>Select Name List: | ||
| <%= form_with url: update_display_rules_path, method: :patch, remote: false do %> | ||
| <%= select_tag :rules_name, options_for_select(["allowed_remotes", "allowed_remotes_crm"], selected: nil),{ onchange: "this.form.submit();", prompt: "Please select rule name" } %> | ||
| <% end %> | ||
| </span> | ||
|
|
||
| <br/> | ||
| <span>Rules Name: <%= raw @rule_name%></span> | ||
| <br/> | ||
| <span>Allowed IPs: <%= raw @allowed_ips_output%></span> | ||
| <% end %> | ||
|
|
||
| <br/><br/> | ||
|
|
||
| <%= form_for @firewall , method: :post do |f| %> | ||
| <div> | ||
| <%= f.label :name, "Name Rule" %> | ||
| <%= f.text_field :name %> | ||
| </div> | ||
| <br/> | ||
| <div> | ||
| <%= f.label :ipAddress, "IP Allow" %> | ||
| <%= f.text_field :ipAddress %> | ||
| </div> | ||
| <br/> | ||
| <div> | ||
| <%= f.submit "Submit", class: "btn btn-primary" %> | ||
| </div> | ||
| <% end %> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,6 +23,9 @@ | |
| <li class="nav-item"> | ||
| <a class="nav-link" href="/admin/vpn_configurations">Configuration</a> | ||
| </li> | ||
| <li class="nav-item"> | ||
| <a class="nav-link" href="/firewall/rules">IP</a> | ||
| </li> | ||
| <% end %> | ||
| <li class="nav-item"> | ||
| <a class="nav-link" href="/logout">Logout</a> | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,19 +1,25 @@ | ||
| <table class="table table-striped table-hover"> | ||
| <thead class="table-light"> | ||
| <tr> | ||
| <th>User</th> | ||
| <th>VPN Device</th> | ||
| <th colspan="2"></th> | ||
| <th>Row</th> | ||
| <th>User ID</th> | ||
| <th>User</th> | ||
| <th>Device IP</th> | ||
| <th>Device description</th> | ||
| <th colspan="2"></th> | ||
| </tr> | ||
| </thead> | ||
|
|
||
| <tbody> | ||
| <% @vpn_devices.each do |vpn_device| %> | ||
| <% @vpn_devices.each_with_index do |vpn_device,index| %> | ||
| <tr> | ||
| <td><%= vpn_device.user.name %></td> | ||
| <td><%= link_to vpn_device.description, vpn_device %></td> | ||
|
|
||
| <td><%= link_to 'Destroy', vpn_device, method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-danger btn-sm' %></td> | ||
| <td><%= index+1 %></td> | ||
| <td><%= vpn_device.user.id %></td> | ||
| <td><%= vpn_device.user.name %></td> | ||
| <td><%= vpn_device.ip_allocation.ip_address %></td> | ||
| <td><%= vpn_device.description %></td> | ||
| <td><%= link_to 'Remove Device', vpn_device, data: { turbo_method: :delete, turbo_confirm: 'Are you sure?' }, class: 'btn btn-danger btn-sm' %></td> | ||
| <td><%= link_to 'Show Device', vpn_device, data: { turbo_method: :get }, class: 'btn btn-primary btn-sm' %></td> | ||
| </tr> | ||
| <% end %> | ||
| </tbody> | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,7 +6,7 @@ | |
| <%= form_with model: vpn_device do |form| %> | ||
| <div class="row"> | ||
| <div class="col-md-3"> | ||
| <%= form.text_field :description, id: "description", class: "form-control", placeholder: "Device Description" %> | ||
| <%= form.text_field :description, id: "description", class: "form-control", placeholder: "Device Description" , required: true %> | ||
| </div> | ||
|
|
||
| <div class="col-md-3"> | ||
|
|
@@ -31,11 +31,12 @@ | |
| </div> | ||
| </div> | ||
| <% end %> | ||
| <br/> | ||
| <% end %> | ||
| <% end %> | ||
|
|
||
| <% if vpn_devices_require_updates.count == 0 %> | ||
| <%= link_to 'Add a VPN Device', new_vpn_device_path, class: 'btn btn-primary btn-sm' %> | ||
| <% if vpn_devices.count == 0 && vpn_devices_require_updates.count == 0 %> | ||
| <%= button_tag "Add a VPN Device", onclick: "window.location.href='#{new_vpn_device_path}'", class: "btn btn-primary btn-sm" %> | ||
| <% end %> | ||
| <br> | ||
| <br> | ||
|
|
@@ -93,15 +94,7 @@ | |
| <h6 class="card-title"> <%= vpn_device.ip_allocation.ip_address %></h6> | ||
| </div> | ||
| </div> | ||
| <div class="row"> | ||
| <div class="col-sm-4"> | ||
| <h6 class="card-title">Accessible remote networks</h6> | ||
| </div> | ||
| <div class="col-sm-8"> | ||
| <td></td> | ||
| <h6 class="card-title"> <%= @vpn_configuration.network_addresses.map(&:network_address).join(", ") %></h6> | ||
| </div> | ||
| </div> | ||
|
|
||
| <br/> | ||
|
|
||
| <%= link_to 'Download Configuration', download_config_path(vpn_device.id), class: 'btn btn-primary btn-sm' %> | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,18 +6,23 @@ | |
| <table class="table table-striped table-hover"> | ||
| <thead class="table-light"> | ||
| <tr> | ||
| <th>Row</th> | ||
| <th>User ID</th> | ||
| <th>User</th> | ||
| <th>Device IP</th> | ||
| <th>Device description</th> | ||
| <th colspan="2"></th> | ||
| </tr> | ||
| </thead> | ||
|
|
||
| <tbody> | ||
| <% @vpn_devices.each do |vpn_device| %> | ||
| <% @vpn_devices.each_with_index do |vpn_device,index| %> | ||
| <tr> | ||
| <td><%= index+1 %></td> | ||
| <td><%= vpn_device.user.id %></td> | ||
| <td><%= vpn_device.user.name %></td> | ||
| <td><%= vpn_device.ip_allocation.ip_address %></td> | ||
| <td><%= vpn_device.description %></td> | ||
|
|
||
| <td><%= link_to 'Remove Device', vpn_device, data: { turbo_method: :delete, turbo_confirm: 'Are you sure?' }, class: 'btn btn-danger btn-sm' %></td> | ||
| <td><%= link_to 'Show Device', vpn_device, data: { turbo_method: :get }, class: 'btn btn-primary btn-sm' %></td> | ||
| </tr> | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -57,16 +57,6 @@ | |
| <%= @vpn_device.ip_allocation.ip_address %></h6> | ||
| </div> | ||
| </div> | ||
| <div class="row"> | ||
| <div class="col-sm-4"> | ||
| <h6 class="card-title">Accessible remote networks</h6> | ||
| </div> | ||
| <div class="col-sm-8"> | ||
| <td></td> | ||
| <h6 class="card-title"> | ||
| <%= @vpn_configuration.network_addresses.map(&:network_address).join(", ") %></h6> | ||
| </div> | ||
| </div> | ||
| <br/> | ||
|
|
||
| <%= link_to "Download Configuration", | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| Rails.application.routes.draw do | ||
| resources :configurations | ||
| resources :vpn_devices | ||
| resources :firewalls | ||
| get 'dns_records/refresh', to: 'dns_records#refresh_zones', as: 'refresh_dns_records' | ||
| resources :dns_records | ||
| get 'home/index' | ||
|
|
@@ -12,8 +13,13 @@ | |
| get 'auth/:provider/callback', to: 'sessions#create' | ||
| get 'auth/failure', to: redirect('/') | ||
| get 'logout', to: 'sessions#destroy', as: 'logout' | ||
|
|
||
| get 'admin/users' | ||
| #get 'firewall' , to: 'firewall#index' | ||
| post 'firewalls', to: 'firewalls#create', as: 'firewall_create' | ||
| patch 'firewalls', to: 'firewalls#update_display_rules', as: 'update_display_rules' | ||
|
|
||
| patch 'admin/user/:id', to: 'admin#update_users_admin', as: 'update_users_admin' | ||
|
|
||
| get 'admin/vpn_configurations' | ||
| patch 'admin/vpn_configuration/:id', to: 'admin#update_vpn_configuration', as: 'update_vpn_configuration' | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,9 +40,11 @@ | |
| t.string "uid" | ||
| t.string "email" | ||
| t.string "name" | ||
| t.string "role" | ||
| t.datetime "created_at", null: false | ||
| t.datetime "updated_at", null: false | ||
| t.boolean "admin" | ||
| t.boolean "isDeleted", default: false | ||
| end | ||
|
|
||
| create_table "vpn_configurations", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check failure
Code scanning / CodeQL
Uncontrolled command line Critical
Copilot Autofix
AI over 1 year ago
To fix the problem, we need to ensure that user input is not directly used to construct shell commands. Instead, we should validate and sanitize the input to ensure it is safe. One way to do this is to use a whitelist of allowed values or to escape the input properly. In this case, we can use a whitelist approach to ensure that only valid
rules_namevalues are used.rules_namevalues.rules_nameprovided by the user is in the whitelist.