From 6138ed6f2df5a4a192c73aa15de53dd1fe44725c Mon Sep 17 00:00:00 2001 From: Mawi Man <185532606+mawi-officiel@users.noreply.github.com> Date: Sun, 31 Aug 2025 23:25:29 +0100 Subject: [PATCH] =?UTF-8?q?CIN=20CLI=20v3.0.2=20-=20Security=20and=20Prote?= =?UTF-8?q?ction=20Improvements=20=F0=9F=94=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # CIN CLI v3.0.2 - Security and Protection Improvements 🔒 ## 🛡️ New Security Features ### Protect Sensitive Commands with Sudo Privileges - **Commands Now Protected:** - `delete framework` - Delete CIN Framework - `delete library` - Delete libraries - `rep [pagename]` - Delete pages ### How to Use ```bash # Enable Administration Mode First cin-cli> sudo enable # Now Execute Sensitive Commands cin-cli> delete framework cin-cli> rep mypage ``` ## 🔧 Technical Improvements - Added `requireSudoPermission()` function to check permissions - Clear error messages when there are insufficient permissions - System-wide protection against unintended destructive operations ## 📋 Security Requirements - Administration mode (`sudo enable`) must be enabled before performing any delete operation - Protection applies to all operations Deletion and Removal - Clear User Warning Messages ## 🎯 Purpose of the Update This update meets contributor requests to improve security and prevent unintended destructive actions, providing an additional layer of protection for users. --- --- src/job-frame.go | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/job-frame.go b/src/job-frame.go index c714c91..055bf94 100644 --- a/src/job-frame.go +++ b/src/job-frame.go @@ -17,7 +17,7 @@ import ( ) const ( - JobFrameVersion = "v3.0.1" + JobFrameVersion = "v3.0.2" VERSION = JobFrameVersion APP_NAME = "CIN Framework CLI" COPYRIGHT_TEXT = "© CIN Framework — All Rights Reserved." @@ -439,6 +439,16 @@ func handleColorCommand(args []string) { } } +func requireSudoPermission(commandName string) bool { + if !adminMode { + fmt.Printf("%s[ERROR]%s %sThis command requires administrative privileges%s\n", getColorRed(), getColorReset(), getColorYellow(), getColorReset()) + fmt.Printf("%s[INFO]%s %sPlease enable admin mode first using: %ssudo enable%s\n", getColorBlue(), getColorReset(), getColorWhite(), getColorCyan(), getColorReset()) + fmt.Printf("%s[SECURITY]%s %sCommand '%s' blocked for security reasons%s\n", getColorMagenta(), getColorReset(), getColorRed(), commandName, getColorReset()) + return false + } + return true +} + func handleClearCommand() { if runtime.GOOS == "windows" { fmt.Print("\033[2J\033[H") @@ -496,6 +506,11 @@ require_once __DIR__ . '/cin/cin.php'; } func handleRemovePageCommand(args []string) { + // Require sudo permissions for remove operations + if !requireSudoPermission("rep") { + return + } + if len(args) == 0 { fmt.Printf("%s[ERROR]%s %sPage name is required%s\n", getColorRed(), getColorReset(), getColorYellow(), getColorReset()) fmt.Printf("%sUsage:%s rep [pagename]\n", getColorDim(), getColorReset()) @@ -697,6 +712,11 @@ func handleInstallFramework(args []string) { } func handleDeleteCommand(args []string) { + // Require sudo permissions for delete operations + if !requireSudoPermission("delete") { + return + } + if len(args) == 0 { fmt.Printf("%s[ERROR]%s Usage: delete [framework|library] [options]\n", getColorRed(), getColorReset()) return