Skip to content

Conversation

Ayash-Bera
Copy link

@Ayash-Bera Ayash-Bera commented Jun 13, 2025

User description

Description

Fixes #999

Added comprehensive Arch Linux installation support through the Arch User Repository (AUR), making keyshade easily accessible to the entire Arch Linux ecosystem. This contribution enables seamless installation for Arch Linux, Manjaro, EndeavourOS, and other Arch-based distributions.

Fixes #[999]

Dependencies

sudo pacman -Syu --noconfirm && \
sudo pacman -S --noconfirm base-devel git nodejs npm python gcc make

Package is live at: https://aur.archlinux.org/packages/keyshade

Screenshots of relevant screens

image
image
image

Developer's checklist

  • My PR follows the style guidelines of this project
  • I have performed a self-check on my work

If changes are made in the code:

  • I have followed the coding guidelines
  • My changes in code generate no new warnings
  • My changes are breaking another fix/feature of the project
  • I have added test cases to show that my feature works
  • I have added relevant screenshots in my PR
  • There are no UI/UX issues

Documentation Update

  • This PR requires an update to the documentation at docs.keyshade.xyz
  • I have made the necessary updates to the documentation, or no documentation changes are required.

PR Type

Enhancement


Description

• Adds comprehensive Arch Linux installation support through the Arch User Repository (AUR)
• Implements complete CLI application with command structure for keyshade management
• Creates base command architecture with shared functionality including error handling and Sentry integration
• Adds workspace management commands (create, list, get, delete, membership operations)
• Implements project management with CRUD operations, fork handling, and environment import
• Provides secret and variable management with encryption, decryption, versioning, and rollback capabilities
• Adds live configuration updates with WebSocket integration for real-time changes
• Implements profile management system for CLI configuration and authentication
• Creates secret scanning functionality to detect hardcoded credentials in files
• Adds environment management within projects with full CRUD operations
• Implements private key management for encryption/decryption operations
• Provides comprehensive pagination, logging, and error reporting utilities


Changes walkthrough 📝

Relevant files
Enhancement
64 files
run.command.ts
Add live configuration update command with WebSocket integration

packages/aur/src/package/src/commands/run.command.ts

• Implements a RunCommand class that executes commands with live
configuration updates
• Establishes WebSocket connection to receive
real-time configuration changes from the API
• Fetches and decrypts
secrets/variables, then injects them as environment variables

Automatically restarts the command process when configuration changes
are detected

+276/-0 
base.command.ts
Implement base command class with shared CLI functionality

packages/aur/src/package/src/commands/base.command.ts

• Creates abstract base class for all CLI commands with common
functionality
• Handles global context setup including API key, base
URL, and metrics configuration
• Provides error logging and reporting
capabilities with Sentry integration
• Manages command registration,
options, arguments, and HTTP request validation

+249/-0 
scan.command.ts
Add secret scanning command for hardcoded credential detection

packages/aur/src/package/src/commands/scan.command.ts

• Implements secret scanning functionality for detecting hardcoded
secrets in files
• Supports scanning specific files, current Git
changes, or entire project directory
• Integrates with
@keyshade/secret-scan package for secret detection
• Provides ignore
functionality via comments (keyshade-ignore, keyshade-ignore-all)

+213/-0 
create.profile.ts
Implement profile creation command with validation and prompts

packages/aur/src/package/src/commands/profile/create.profile.ts

• Creates new user profiles with API key, base URL, and metrics
settings
• Validates input using Zod schema for profile name and API
key format
• Supports interactive prompts and command-line options for
profile creation
• Handles profile overwriting with user confirmation

+192/-0 
import.project.ts
Add environment file import functionality for projects     

packages/aur/src/package/src/commands/project/import.project.ts

• Imports environment variables from .env files into keyshade projects

• Automatically detects and categorizes secrets vs variables using
secret scanning
• Creates secrets and variables in specified project
and environment
• Provides confirmation prompts and error handling for
import operations

+183/-0 
create.secret.ts
Implement secret creation command with multi-environment support

packages/aur/src/package/src/commands/secret/create.secret.ts

• Creates new secrets in keyshade projects with name, note, and
rotation settings
• Supports multiple environment entries with
validation
• Provides interactive prompts for missing required fields

• Includes comprehensive usage examples and error handling

+158/-0 
update.secret.ts
Add secret update command with entry management                   

packages/aur/src/package/src/commands/secret/update.secret.ts

• Updates existing secrets with new values, metadata, and rotation
settings
• Supports adding new environment entries to existing secrets

• Includes decryption options and private key handling
• Validates
entry format and provides detailed usage examples

+160/-0 
create.variable.ts
Implement variable creation command with environment entries

packages/aur/src/package/src/commands/variable/create.variable.ts

• Creates new variables in keyshade projects with name and note

Supports multiple environment entries with format validation

Provides interactive prompts and comprehensive usage examples

Handles entry parsing and validation with error reporting

+150/-0 
create.project.ts
Add project creation command with environment and access control

packages/aur/src/package/src/commands/project/create.project.ts

• Creates new projects in workspaces with configurable settings

Supports environment creation, access levels, and private key storage

• Parses environment specifications with name and description

Provides detailed project information upon successful creation

+141/-0 
create.role.ts
Implement workspace role creation with project associations

packages/aur/src/package/src/commands/workspace/role/create.role.ts

• Creates workspace roles with authorities and project-environment
associations
• Validates project and environment count matching

Supports color coding and detailed role configuration
• Displays
comprehensive role information after creation

+138/-0 
update.role.ts
Add workspace role update command with validation               

packages/aur/src/package/src/commands/workspace/role/update.role.ts

• Updates existing workspace roles with new authorities and
associations
• Validates project-environment mapping consistency

Supports modification of role properties including color and
description
• Provides detailed updated role information display

+134/-0 
controller-instance.ts
Create singleton controller instance manager for API clients

packages/aur/src/package/src/util/controller-instance.ts

• Implements singleton pattern for API client controller management

Initializes all keyshade API controllers with base URL configuration

Provides centralized access to workspace, project, secret, and
variable controllers
• Ensures proper initialization before controller
access

+134/-0 
update.variable.ts
Implement variable update command with entry management   

packages/aur/src/package/src/commands/variable/update.variable.ts

• Updates existing variables with new values and metadata
• Supports
adding new environment entries with format validation
• Provides
comprehensive usage examples and error handling
• Validates entry
format and handles parsing errors gracefully

+124/-0 
revisions.secret.ts
Add secret revision history command with decryption support

packages/aur/src/package/src/commands/secret/revisions.secret.ts

• Fetches and displays all revisions of a specific secret
• Supports
optional value decryption and pagination
• Shows revision history with
version, creation date, and creator information
• Includes
comprehensive usage examples for different scenarios

+121/-0 
list.profile.ts
Implement profile listing command with table formatting   

packages/aur/src/package/src/commands/profile/list.profile.ts

• Lists all user profiles in a formatted table display
• Supports
verbose mode showing API keys, URLs, and metrics settings
• Highlights
default profile and provides clean table formatting
• Uses CLI table
library for professional output presentation

+103/-0 
list.secret.ts
Add secret listing command with decryption and pagination

packages/aur/src/package/src/commands/secret/list.secret.ts

• Lists all secrets within a project with environment-specific values

• Supports optional value decryption and pagination
• Displays secret
metadata including creation date and creator
• Provides comprehensive
usage examples and error handling

+109/-0 
configuration.ts
Implement configuration file management utilities               

packages/aur/src/package/src/util/configuration.ts

• Manages configuration file operations for profiles and private keys

• Handles cross-platform file path resolution (Windows/Unix)
• Creates
configuration directories and files as needed
• Provides read/write
operations for project root configuration

+92/-0   
update.profile.ts
Add profile update command with renaming support                 

packages/aur/src/package/src/commands/profile/update.profile.ts

• Updates existing user profiles with new settings
• Handles profile
renaming with default profile reference updates
• Validates profile
existence before modification
• Supports updating API key, base URL,
and metrics settings

+105/-0 
init.command.ts
Implement project initialization command for live-updates

packages/aur/src/package/src/commands/init.command.ts

• Initializes project configuration for live-updates functionality

Creates keyshade.json and private key configuration files
• Supports
interactive prompts and overwrite protection
• Configures workspace,
project, environment, and decryption settings

+116/-0 
revisions.variable.ts
Add variable revision history command with pagination       

packages/aur/src/package/src/commands/variable/revisions.variable.ts

• Fetches and displays all revisions of a specific variable
• Shows
revision history with version, creation date, and creator information

• Supports pagination for large revision histories
• Provides
comprehensive usage examples and error handling

+96/-0   
rollback.variable.ts
Implement variable rollback command with version control 

packages/aur/src/package/src/commands/variable/rollback.variable.ts

• Rolls back variables to previous versions in specific environments

Validates required environment and version parameters
• Provides
rollback count information upon success
• Includes comprehensive usage
examples and error handling

+99/-0   
rollback.secret.ts
Add secret rollback command with version control                 

packages/aur/src/package/src/commands/secret/rollback.secret.ts

• Rolls back secrets to previous versions in specific environments

Validates required environment and version parameters
• Provides
rollback count information upon success
• Includes comprehensive usage
examples and error handling

+98/-0   
create.environment.ts
Implement environment creation command for projects           

packages/aur/src/package/src/commands/environment/create.environment.ts

• Creates new environments within projects
• Supports interactive
prompts for missing environment name
• Validates project slug
requirement and provides error handling
• Displays created environment
information with slug and timestamps

+94/-0   
list.variable.ts
Add variable listing command with pagination support         

packages/aur/src/package/src/commands/variable/list.variable.ts

• Lists all variables within a project with environment-specific
values
• Supports pagination for large variable collections
• Displays
variable metadata including creation date and creator
• Provides
comprehensive usage examples and error handling

+84/-0   
update.environment.ts
Add environment update command implementation                       

packages/aur/src/package/src/commands/environment/update.environment.ts

• Implements UpdateEnvironment command class extending BaseCommand

Provides options for updating environment name and description

Handles environment slug validation and API calls for environment
updates

+76/-0   
get-all-members.membership.ts
Add workspace membership listing command                                 

packages/aur/src/package/src/commands/workspace/membership/get-all-members.membership.ts

• Creates GetAllMembersOfWorkspaceCommand to list workspace members

Includes pagination options and workspace slug argument
• Displays
member emails and their associated roles

+68/-0   
transfer-ownership.membership copy.ts
Add workspace ownership transfer command                                 

packages/aur/src/package/src/commands/workspace/membership/transfer-ownership.membership copy.ts

• Implements TransferOwnershipCommand for workspace ownership transfer

• Accepts workspace slug and new owner email as parameters
• Handles
API calls to transfer workspace ownership

+67/-0   
get.role.ts
Add workspace role retrieval command                                         

packages/aur/src/package/src/commands/workspace/role/get.role.ts

• Creates GetRoleCommand to fetch specific workspace role details

Displays role information including authorities and associated
projects
• Takes workspace role slug as argument

+60/-0   
list.role.ts
Add workspace role listing command                                             

packages/aur/src/package/src/commands/workspace/role/list.role.ts

• Implements ListRoleCommand to list all workspace roles
• Includes
pagination support and workspace slug argument
• Displays role names
and slugs in formatted output

+65/-0   
delete.profile.ts
Add profile deletion command implementation                           

packages/aur/src/package/src/commands/profile/delete.profile.ts

• Creates DeleteProfile command for removing CLI profiles
• Includes
confirmation prompt for default profile deletion
• Handles profile
existence validation and configuration updates

+56/-0   
resend-invitation.membership.ts
Add workspace invitation resend command                                   

packages/aur/src/package/src/commands/workspace/membership/resend-invitation.membership.ts

• Implements ResendInvitationCommand for workspace invitation
management
• Accepts workspace slug and user email as parameters

Handles API calls to resend workspace invitations

+62/-0   
update.private-key.ts
Add private key update command                                                     

packages/aur/src/package/src/commands/config/private-key/update.private-key.ts

• Creates UpdatePrivateKey command for modifying stored private keys

Validates workspace and project parameters are provided
• Updates
private key configuration for workspace-project combinations

+65/-0   
list.environment.ts
Add environment listing command implementation                     

packages/aur/src/package/src/commands/environment/list.environment.ts

• Implements ListEnvironment command to display project environments

Includes pagination options and project slug validation
• Formats
environment output with names and slugs

+65/-0   
cancel-invitation.membership.ts
Add workspace invitation cancellation command                       

packages/aur/src/package/src/commands/workspace/membership/cancel-invitation.membership.ts

• Creates CancelInvitationCommand for canceling workspace invitations

• Takes workspace slug and user email as parameters
• Handles API
calls to cancel pending invitations

+63/-0   
remove.membership.ts
Add workspace user removal command                                             

packages/aur/src/package/src/commands/workspace/membership/remove.membership.ts

• Implements RemoveUserCommand for removing users from workspaces

Accepts comma-separated list of user emails to remove
• Handles bulk
user removal from workspace memberships

+63/-0   
sync.project.ts
Add project fork synchronization command                                 

packages/aur/src/package/src/commands/project/sync.project.ts

• Creates SyncProject command for synchronizing forked projects

Provides hard sync option for complete parent project copying

Handles API calls to sync forked projects with their parents

+62/-0   
get.environment.ts
Add environment retrieval command implementation                 

packages/aur/src/package/src/commands/environment/get.environment.ts

• Implements GetEnvironment command to fetch specific environment
details
• Validates environment slug parameter and displays
environment information
• Shows environment metadata including
creation and update timestamps

+60/-0   
add.private-key.ts
Add private key addition command                                                 

packages/aur/src/package/src/commands/config/private-key/add.private-key.ts

• Creates AddPrivateKey command for storing new private keys

Validates workspace and project parameters are required
• Adds private
key to configuration for workspace-project combinations

+59/-0   
get.project.ts
Add project retrieval command implementation                         

packages/aur/src/package/src/commands/project/get.project.ts

• Implements GetProject command to fetch specific project details

Displays comprehensive project information including keys and access
level
• Takes project slug as argument for project retrieval

+54/-0   
delete.private-key.ts
Add private key deletion command                                                 

packages/aur/src/package/src/commands/config/private-key/delete.private-key.ts

• Creates DeletePrivateKey command for removing stored private keys

Validates existence of private key before deletion
• Removes private
key from configuration for workspace-project combinations

+55/-0   
get.workspace.ts
Add workspace retrieval command implementation                     

packages/aur/src/package/src/commands/workspace/get.workspace.ts

• Implements GetWorkspace command to fetch specific workspace details

• Displays workspace information including creation timestamps and
default status
• Takes workspace slug as argument for workspace
retrieval

+54/-0   
list-invitations.workspace.ts
Add workspace invitations listing command                               

packages/aur/src/package/src/commands/workspace/list-invitations.workspace.ts

• Creates ListInvitations command to display workspace invitations

Includes pagination support for invitation listing
• Shows invitation
details with workspace information and invitation dates

+49/-0   
list-forks.project.ts
Add project forks listing command                                               

packages/aur/src/package/src/commands/project/list-forks.project.ts

• Implements ListProjectForks command to display project forks
• Takes
project slug as argument to list all forks of a project
• Formats fork
output with project names and slugs

+53/-0   
list.project.ts
Add project listing command implementation                             

packages/aur/src/package/src/commands/project/list.project.ts

• Creates ListProject command to display workspace projects
• Takes
workspace slug as argument for project listing
• Shows project names
and slugs in formatted output

+56/-0   
list.workspace.ts
Add workspace listing command implementation                         

packages/aur/src/package/src/commands/workspace/list.workspace.ts

• Implements ListWorkspace command to display user workspaces

Includes pagination support for workspace listing
• Shows workspace
names and slugs in formatted output

+51/-0   
sentry.ts
Add Sentry error reporting utility                                             

packages/aur/src/package/src/util/sentry.ts

• Creates SentryInstance singleton class for error reporting

Configures Sentry with environment variables and profiling integration

• Provides static methods for exception capture and initialization

+42/-0   
delete.secret.ts
Add secret deletion command implementation                             

packages/aur/src/package/src/commands/secret/delete.secret.ts

• Implements DeleteSecret command for removing secrets
• Takes secret
slug as argument and includes usage examples
• Handles API calls to
delete secrets with success confirmation

+56/-0   
delete.variable.ts
Add variable deletion command implementation                         

packages/aur/src/package/src/commands/variable/delete.variable.ts

• Creates DeleteVariable command for removing variables
• Takes
variable slug as argument and includes usage examples
• Handles API
calls to delete variables with success confirmation

+56/-0   
membership.workspace.ts
Add workspace membership command orchestrator                       

packages/aur/src/package/src/commands/workspace/membership.workspace.ts

• Creates WorkspaceMembershipCommand as parent command for membership
operations
• Registers all membership-related subcommands including
invitations and role management
• Provides centralized access to
workspace membership functionality

+36/-0   
index.ts
Add main CLI application entry point                                         

packages/aur/src/package/src/index.ts

• Sets up main CLI entry point with Commander.js configuration

Registers all command modules and global options like profile and API
key
• Configures version flag and command parsing for the CLI
application

+40/-0   
delete.environment.ts
Add environment deletion command implementation                   

packages/aur/src/package/src/commands/environment/delete.environment.ts

• Implements DeleteEnvironment command for removing environments

Validates environment slug parameter and handles API deletion calls

Provides confirmation of successful environment deletion

+53/-0   
accept-invitation.membership.ts
Add workspace invitation acceptance command                           

packages/aur/src/package/src/commands/workspace/membership/accept-invitation.membership.ts

• Creates AcceptInvitationCommand for accepting workspace invitations

• Takes workspace slug as argument for invitation acceptance
• Handles
API calls to accept workspace membership invitations

+49/-0   
unlink.project.ts
Add project fork unlinking command                                             

packages/aur/src/package/src/commands/project/unlink.project.ts

• Implements UnlinkProject command for disconnecting forked projects

Takes project slug as argument to unlink from parent project
• Handles
API calls to remove fork relationship

+49/-0   
leave.membership.ts
Add workspace leave command implementation                             

packages/aur/src/package/src/commands/workspace/membership/leave.membership.ts

• Creates LeaveWorkspaceCommand for leaving workspace memberships

Takes workspace slug as argument for leaving workspace
• Handles API
calls to remove user from workspace

+49/-0   
delete.role.ts
Add workspace role deletion command                                           

packages/aur/src/package/src/commands/workspace/role/delete.role.ts

• Implements DeleteRoleCommand for removing workspace roles
• Takes
workspace role slug as argument for role deletion
• Handles API calls
to delete workspace roles with confirmation

+48/-0   
logger.ts
Add colored logging utility with Sentry integration           

packages/aur/src/package/src/util/logger.ts

• Creates Logger namespace with colored console logging functions

Provides log, info, error, warn methods with timestamps
• Integrates
with Sentry for error reporting functionality

+42/-0   
use.profile.ts
Add profile activation command implementation                       

packages/aur/src/package/src/commands/profile/use.profile.ts

• Implements UseProfile command for setting default CLI profile

Validates profile existence and updates configuration
• Sets the
specified profile as the active default profile

+41/-0   
delete.workspace.ts
Add workspace deletion command implementation                       

packages/aur/src/package/src/commands/workspace/delete.workspace.ts

• Creates DeleteWorkspace command for removing workspaces
• Takes
workspace slug as argument for workspace deletion
• Handles API calls
to delete workspaces with success confirmation

+48/-0   
delete.project.ts
Add project deletion command implementation                           

packages/aur/src/package/src/commands/project/delete.project.ts

• Implements DeleteProject command for removing projects
• Takes
project slug as argument for project deletion
• Handles API calls to
delete projects with success confirmation

+48/-0   
workspace.command.ts
Add workspace command orchestrator                                             

packages/aur/src/package/src/commands/workspace.command.ts

• Creates WorkspaceCommand as parent command for workspace operations

• Registers all workspace-related subcommands including CRUD
operations
• Provides centralized access to workspace management
functionality

+36/-0   
project.command.ts
Add project command orchestrator                                                 

packages/aur/src/package/src/commands/project.command.ts

• Creates ProjectCommand as parent command for project operations

Registers all project-related subcommands including CRUD and fork
operations
• Provides centralized access to project management
functionality

+36/-0   
decrypt.ts
Add cryptographic decryption utility function                       

packages/aur/src/package/src/util/decrypt.ts

• Implements decrypt function using eccrypto for data decryption

Handles ECIES decryption with private key and encrypted data parsing

Returns decrypted data as string for secret management

+31/-0   
pagination-options.ts
Add reusable pagination options configuration                       

packages/aur/src/package/src/util/pagination-options.ts

• Defines PAGINATION_OPTION constant with common pagination command
options
• Includes page, limit, order, sort, and search parameters

Provides reusable pagination configuration for list commands

+31/-0   
secret.command.ts
Add secret command orchestrator                                                   

packages/aur/src/package/src/commands/secret.command.ts

• Creates SecretCommand as parent command for secret operations

Registers all secret-related subcommands including CRUD and revision
operations
• Provides centralized access to secret management
functionality

+28/-0   
Configuration changes
1 files
env.ts
Add environment variable validation utility                           

packages/aur/src/package/src/util/env.ts

• Defines environment variable validation schema using Zod
• Validates
Sentry configuration variables with proper type checking
• Extends
global NodeJS ProcessEnv interface with typed environment variables

+44/-0   
Additional files
44 files
.SRCINFO +14/-0   
PKGBUILD +41/-0   
.BUILDINFO +1716/-0
.MTREE [link]   
.PKGINFO +13/-0   
fcc3475b385c958b8275c8e48ba6e49e496585 +1/-0     
fcc3475b385c958b8275c8e48ba6e49e496585.debug +1/-0     
6054152e25511c9c05013e7bf752bd048cd8ed +1/-0     
6054152e25511c9c05013e7bf752bd048cd8ed.debug +1/-0     
feaae14cc583bebcc4d0de0b66d85c83feecc3 +1/-0     
feaae14cc583bebcc4d0de0b66d85c83feecc3.debug +1/-0     
.BUILDINFO +1716/-0
.MTREE [link]   
.PKGINFO +16/-0   
keyshade +1/-0     
.eslintrc.cjs +33/-0   
.swcrc +26/-0   
CHANGELOG.md +149/-0 
README.md +46/-0   
esbuild.config.js +19/-0   
package.json +72/-0   
config.command.ts +17/-0   
private-key.config.ts +24/-0   
list.private-key.ts +63/-0   
update.config.ts +78/-0   
environment.command.ts +26/-0   
profile.command.ts +26/-0   
fork.project.ts +75/-0   
update.project.ts +80/-0   
create.workspace.ts +75/-0   
export.workspace.ts +72/-0   
decline-invitation.membership.ts +49/-0   
invite.membership.ts +73/-0   
update-role.membership.ts +78/-0   
role.workspace.ts +26/-0   
search.workspace.ts +83/-0   
update.workspace.ts +77/-0   
command.types.d.ts +17/-0   
run.types.d.ts +16/-0   
index.types.d.ts +34/-0   
date-formatter.ts +17/-0   
profile.ts +24/-0   
tsconfig.json +33/-0   
tsup.config.ts +15/-0   

Need help?
  • Type /help how to ... in the comments thread for any questions about Qodo Merge usage.
  • Check out the documentation for more information.
  • Copy link
    Contributor

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 4 🔵🔵🔵🔵⚪
    🧪 No relevant tests
    🔒 Security concerns

    API key exposure:
    The code in several command files (like run.command.ts) logs API keys and other sensitive information to the console. For example, in profile/list.profile.ts, when the verbose flag is set, it displays API keys in plain text in the console output. This could lead to credential leakage if logs are shared or visible to unauthorized users.

    ⚡ Recommended focus areas for review

    Process Management

    The executeCommand method creates an infinite loop that continuously spawns child processes without proper cleanup. When a process is killed, it doesn't properly handle termination signals or ensure resources are released.

    private async executeCommand(command: string) {
      let childProcess = null
      while (true) {
        if (this.shouldRestart) {
          Logger.info('Restarting command...')
          process.kill(-childProcess.pid)
          this.shouldRestart = false
        }
        if (childProcess === null) {
          childProcess = spawn(command, {
            // @ts-expect-error this just works
            stdio: ['inherit', 'pipe', 'pipe'],
            shell: true,
            env: { ...process.env, ...this.processEnvironmentalVariables },
            detached: true
          })
    
          childProcess.stdout.on('data', (data) => {
            process.stdout.write(`[COMMAND] ${data}`)
          })
    
          childProcess.stderr.on('data', (data) => {
            process.stderr.write(`[COMMAND] ${data}`)
          })
    
          childProcess.on('exit', () => {
            Logger.info('Command exited.')
            childProcess = null
          })
        }
        await this.sleep(1000)
      }
    }
    Security Scanning Logic

    The scanFiles method has potential issues with file processing - it doesn't properly handle large files, has no timeout mechanism, and the regex matching could be vulnerable to regex denial of service (ReDoS) attacks.

    private scanFiles(allFiles: string[]) {
      const foundSecrets = []
      let skipNextLine = false
      for (const file of allFiles) {
        const stats = statSync(file)
        if (stats.isFile()) {
          // Skip the file if it has an ignored extension like images, videos, etc.
          if (ignoredExtensions.includes(file.split('.').pop())) continue
          const content = readFileSync(file, 'utf8').split(/\r?\n/)
    
          // Skip the file if ignore comment is found in the first line
          if (content[0].includes('keyshade-ignore-all')) {
            continue
          }
    
          content.forEach((line, index) => {
            // Skip the next line if ignore comment is found in the previous line
            if (skipNextLine) {
              skipNextLine = false
              return
            }
    
            if (line.includes('keyshade-ignore')) {
              skipNextLine = true
              return
            }
            const { found, regex } = secretDetector.detect(line) as {
              found: boolean
              regex: RegExp
            }
            if (found) {
              const matched = line.match(regex)
              const highlightedLine = line.replace(regex, matched[0]).trim()
              foundSecrets.push({
                file,
                line: index + 1,
                content: highlightedLine
              })
            }
          })
        }
      }
    Path Handling

    The configuration file path handling doesn't properly account for different operating systems. The code uses forward slashes which may cause issues on Windows systems.

    export const getOsType = (): 'unix' | 'windows' => {
      return process.platform === 'win32' ? 'windows' : 'unix'
    }
    
    export const getHomeDirectory = (): string => {
      const osType = getOsType()
      return osType === 'windows' ? 'USERPROFILE' : 'HOME'
    }
    
    export const getProfileConfigurationFilePath = () => {
      const home = getHomeDirectory()
      return `${process.env[home]}/.keyshade/profiles.json`
    }
    
    export const getPrivateKeyConfigurationFilePath = () => {
      const home = getHomeDirectory()
      return `${process.env[home]}/.keyshade/private-keys.json`
    }

    Copy link
    Contributor

    codiumai-pr-agent-free bot commented Jun 13, 2025

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Impact
    Possible issue
    Add null check

    The code is attempting to kill a process group using a negative PID, but doesn't
    check if childProcess exists or is running first. This could cause a runtime
    error if childProcess is null or doesn't have a valid pid.

    packages/aur/src/package/src/commands/run.command.ts [157-161]

    -if (this.shouldRestart) {
    +if (this.shouldRestart && childProcess && childProcess.pid) {
         Logger.info('Restarting command...')
         process.kill(-childProcess.pid)
         this.shouldRestart = false
       }

    [To ensure code accuracy, apply this suggestion manually]

    Suggestion importance[1-10]: 9

    __

    Why: The suggestion correctly identifies a potential runtime error. If this.shouldRestart is true but childProcess is null (e.g., after it has exited), accessing childProcess.pid would crash the command. The proposed change prevents this by ensuring childProcess and its pid exist before attempting to kill the process.

    High
    Fix invalid entry handling

    The code incorrectly pushes entries to the array even when environmentSlug or
    value is missing. This will create invalid entries with undefined values. Add a
    condition to only push valid entries.

    packages/aur/src/package/src/commands/secret/create.secret.ts [125-149]

     if (rawEntries) {
       for (const entry of rawEntries) {
         // Check for entry format
         if (!entry.match(/^[a-zA-Z0-9\-_+:[a-zA-Z0-9_\-!@#$%^&*()_+=[ ]+$/)) {
           Logger.warn(
             `Invalid entry format. Expected <environment slug>:<value> but got ${entry}`
           )
         } else {
           const [environmentSlug, value] = entry
             .split('=')
             .map((s: string) => s.trim())
     
           if (!environmentSlug || !value) {
             Logger.warn(
               `Invalid entry format. Expected <environment slug>:<value> but got ${entry}`
             )
    +      } else {
    +        entries.push({
    +          value,
    +          environmentSlug
    +        })
           }
    -
    -      entries.push({
    -        value,
    -        environmentSlug
    -      })
         }
       }
     }

    [To ensure code accuracy, apply this suggestion manually]

    Suggestion importance[1-10]: 8

    __

    Why: The suggestion correctly points out that an entry with a missing environmentSlug or value would be pushed to the entries array with undefined properties. This would likely cause an error in the subsequent API call. The proposed else block correctly ensures that only fully valid entries are added.

    Medium
    Fix git status parsing

    The function doesn't handle git status output format correctly. Git status -s
    output has status codes at the beginning, and the file path might be at index 1
    or later depending on the status. This can lead to undefined paths.

    packages/aur/src/package/src/commands/scan.command.ts [197-212]

     private getChangedFiles(): string[] {
       const output = execSync('git status -s').toString()
       const files = output
         .split('\n')
    -    .filter((line) => {
    -      if (typeof line === 'undefined') {
    -        return false
    -      }
    -      return line
    +    .filter((line) => line && line.trim())
    +    .map((line) => {
    +      const parts = line.trim().split(/\s+/)
    +      // The file path is typically the second item (index 1) or third item (index 2) if there's a staging indicator
    +      const filePath = parts.length > 1 ? parts[parts.length - 1] : null
    +      return filePath ? path.resolve(process.cwd(), filePath) : null
         })
    -    .map((line) => {
    -      line = line.trim().split(' ')[1]
    -      return path.resolve(process.cwd(), line)
    -    })
    +    .filter(Boolean)
       return files
     }

    [To ensure code accuracy, apply this suggestion manually]

    Suggestion importance[1-10]: 8

    __

    Why: The suggestion correctly identifies that the original parsing of git status -s output is brittle. It assumes the file path is always the second element after splitting by a single space, which fails for renamed files (e.g., R src/old.js -> src/new.js) or files with spaces. The improved code is more robust by handling various statuses and correctly extracting the file path.

    Medium
    Handle all error types

    Add an else clause to handle non-ZodError exceptions. Currently, if an error
    occurs that isn't a ZodError, it will be silently ignored, which could lead to
    unexpected behavior.

    packages/aur/src/package/src/util/env.ts [32-44]

     try {
       zodEnv.parse(process.env)
     } catch (error) {
       if (error instanceof z.ZodError) {
         const { fieldErrors } = error.flatten()
         const errorMessage = Object.entries(fieldErrors)
           .map(([field, errors]) => `${field}: ${errors?.join(', ')}`)
           .join('\n  ')
         throw new Error(
           `Missing environment variables: \n  ${errorMessage}\n  Please check your .env file.`
         )
    +  } else {
    +    throw new Error(`Error validating environment variables: ${error}`)
       }
     }

    [To ensure code accuracy, apply this suggestion manually]

    Suggestion importance[1-10]: 7

    __

    Why: The suggestion correctly identifies a potential issue where non-ZodError exceptions are caught but not handled, leading to silent failures. Adding an else block to re-throw other errors makes the environment variable validation more robust.

    Medium
    General
    Fix file naming

    The filename contains "copy" which suggests this is a duplicate file. Rename the
    file to remove "copy" from the filename to follow proper naming conventions and
    avoid confusion.

    packages/aur/src/package/src/commands/workspace/membership/transfer-ownership.membership copy.ts [10]

    +export default class TransferOwnershipCommand extends BaseCommand {
     
    -

    [To ensure code accuracy, apply this suggestion manually]

    Suggestion importance[1-10]: 6

    __

    Why: The suggestion correctly points out that the filename transfer-ownership.membership copy.ts likely indicates an accidental commit of a copied file. Renaming it is important for maintaining a clean and understandable codebase, and preventing potential build or runtime issues.

    Low
    Remove debug logging

    Remove the debug console.log statement that outputs options to the console. This
    statement was likely used during development and should be removed before
    production deployment.

    packages/aur/src/package/src/commands/project/fork.project.ts [56]

    -console.log(options)
    +// Options are already being used in the API call below
    • Apply / Chat
    Suggestion importance[1-10]: 3

    __

    Why: The suggestion correctly identifies a console.log statement that appears to be for debugging purposes. Removing such statements is good practice for code cleanliness and production readiness. The impact is minor.

    Low
    Fix spelling error

    Fix the typo in the success message. The word "sucessfully" is misspelled and
    should be "successfully" for proper English spelling.

    packages/aur/src/package/src/commands/workspace/membership/accept-invitation.membership.ts [43]

    -Logger.info('Accepted invitation sucessfully!')
    +Logger.info('Accepted invitation successfully!')

    [To ensure code accuracy, apply this suggestion manually]

    Suggestion importance[1-10]: 3

    __

    Why: The suggestion correctly identifies and fixes a spelling mistake in a log message. While this improves code quality, it's a minor cosmetic change with no impact on functionality.

    Low
    • Update

    @rajdip-b rajdip-b changed the title Aur package for keyshade feat: aur package for keyshade Jun 14, 2025
    @rajdip-b
    Copy link
    Member

    Thanks a lot for this PR!

    @Ayash-Bera
    Copy link
    Author

    @rajdip-b dont merge it yet its present and working but I still need to make some parts better

    @rajdip-b
    Copy link
    Member

    Sure thing!

    @kriptonian1 kriptonian1 changed the title feat: aur package for keyshade [WIP]: aur package for keyshade Jun 14, 2025
    @kriptonian1 kriptonian1 marked this pull request as draft June 14, 2025 11:20
    @kriptonian1
    Copy link
    Contributor

    @Ayash-Bera I have market this PR as draft, once you are done I will mark it as ready for review

    @kriptonian1
    Copy link
    Contributor

    Hey @Ayash-Bera any updates on this PR ??

    @kriptonian1 kriptonian1 changed the title [WIP]: aur package for keyshade [WIP] feat: aur package for keyshade Jul 15, 2025
    @Ayash-Bera
    Copy link
    Author

    Hey @Ayash-Bera any updates on this PR ??

    was caught up in some work :( expect a proper soon

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    Feature request: AUR package distribution
    3 participants