Skip to content

[pull] loki from asbru-cm:loki#86

Open
pull[bot] wants to merge 900 commits into
RogueScholar:lokifrom
asbru-cm:loki
Open

[pull] loki from asbru-cm:loki#86
pull[bot] wants to merge 900 commits into
RogueScholar:lokifrom
asbru-cm:loki

Conversation

@pull

@pull pull Bot commented Mar 3, 2020

Copy link
Copy Markdown

See Commits and Changes for more details.


Created by pull[bot] (v2.0.0-alpha.4)

Can you help keep this open source service alive? 💖 Please sponsor : )

@pull pull Bot added the ⤵️ pull label Mar 3, 2020
@pull
pull Bot requested a review from RogueScholar March 3, 2020 19:54
@pull pull Bot added the merge-conflict Resolve conflicts manually label Mar 4, 2020
gfrenoy and others added 25 commits February 24, 2021 23:15
…unnel (#771)

Signed-off-by: Syco <alberto.rinaudo+torann@gmail.com>
Co-authored-by: Syco <alberto.rinaudo+torann@gmail.com>
Comment thread lib/PACKeyBindings.pm
Comment thread utils/anonymize.pl
print D "\n\n";
close F;
close D;
unlink $file;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The anonymize.pl script unconditionally deletes the user's original input file after creating an anonymized version, causing irreversible data loss without any warning.
Severity: CRITICAL

Suggested Fix

Remove the line unlink $file; from the script to prevent the deletion of the original user file. Alternatively, make the deletion optional by adding a command-line flag like --destructive and only perform the unlink operation if that flag is present.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: utils/anonymize.pl#L105

Potential issue: The standalone script `utils/anonymize.pl` is intended to create an
anonymized version of a user's configuration file for debugging. However, after writing
the new anonymized file to a hardcoded path (`debug.yml`), the script unconditionally
deletes the original input file using `unlink $file;`. There is no warning, confirmation
prompt, or command-line flag to prevent this behavior. This can lead to irreversible
data loss for users who run the script on their primary configuration file, as their
original settings will be permanently deleted.

Did we get this right? 👍 / 👎 to inform future reviews.

Comment thread utils/anonymize.pl
Comment thread lib/method/PACMethod_mosh.pm
Comment thread lib/PACKeePass.pm
waitpid($pid,0);
close Reader;
close ErrReader;
if (@err) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The code uses a shell-vulnerable form of open3() with unsanitized user input ($uid), creating a potential for shell command injection.
Severity: HIGH

Suggested Fix

Use the list form of open3(), which does not invoke a shell and is not vulnerable to command injection. Pass each part of the command as a separate argument in the list, for example: open3(*Writer, *Reader, *ErrReader, $CLI, $$self{kpxc_cli}, 'show', ..., $uid). This should be applied in both testMasterKey() and getFieldValue().

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: lib/PACKeePass.pm#L201

Potential issue: The `open3()` function is called with a single string argument that
includes an unsanitized variable, `$uid`. In Perl, this invokes a shell (`/bin/sh -c`)
to execute the command, creating a command injection vulnerability. An attacker who can
control KeePass entry names (which populate `$uid`) could inject malicious shell
commands. For example, an entry named `test'; malicious_command; 'end` would execute
`malicious_command`. While exploiting this requires prior access to the KeePass
database, it is an unnecessary security risk that violates secure coding principles.

Did we get this right? 👍 / 👎 to inform future reviews.

Comment thread lib/method/PACMethod_ssh.pm
Comment thread lib/edit/PACTermOpts.pm
Comment thread lib/edit/PACExpectEntry.pm
hanspr and others added 2 commits April 6, 2026 11:41
…1174)

- Display key bindings associated with both local and remote commands
- Display key bindings defined in the main preferences or in the connectection itself
Detection of VTE features based on the version is not reliable
Comment thread lib/PACKeePass.pm
Comment on lines +425 to +429
if ($ok eq 'ok') {
my $selection = $w{window}{gui}{treelist}->get_selection();
my $model = $w{window}{gui}{treelist}->get_model();
my @paths = _getSelectedRows($selection);
$entry = $model->get_value($model->get_iter($paths[0]),0);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The application crashes when a user clicks 'OK' in the KeePass dialog without selecting an entry, due to an unguarded access to an empty array.
Severity: HIGH

Suggested Fix

Add a guard condition to verify that the @paths array is not empty before attempting to access its elements. For example: if (@paths) { ... }.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: lib/PACKeePass.pm#L425-L429

Potential issue: In the KeePass entry selection dialog, if a user clicks the 'OK' button
without selecting an entry, the `@paths` array will be empty. The code proceeds to
access `$paths[0]`, which evaluates to `undef`. This `undef` value is then passed to
`$model->get_iter()`, causing the application to crash. This can occur during normal
user interaction, for example, by opening the dialog and immediately clicking 'OK'.

Comment thread lib/PACKeePass.pm
} else {
$cfg = $self->get_cfg();
}
if (version->parse($$self{kpxc_version}) >= version->parse("2.7.0")) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The application crashes when using the KeePass feature if keepassxc-cli is not installed, because it attempts to parse an empty version string.
Severity: HIGH

Suggested Fix

Add a check in _locateEntries() to ensure $$self{kpxc_version} is not an empty string before calling version->parse(). Additionally, consider calling update() after object initialization to correctly disable UI elements when keepassxc-cli is unavailable.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: lib/PACKeePass.pm#L542

Potential issue: If `keepassxc-cli` is not installed, `_setCapabilities()` correctly
sets `$$self{kpxc_version}` to an empty string. However, the UI state is not updated to
disable the KeePass lookup button. When the user clicks this button, `_locateEntries()`
is called, which attempts to parse the empty version string with
`version->parse($$self{kpxc_version})`. This action throws a fatal 'Invalid version
format' exception, crashing the application.

Comment thread asbru-cm
Comment thread asbru-cm
gfrenoy added 2 commits April 6, 2026 18:28
- Make it compatible with glade 3.40
- Suppress deprecated "stock icon"
Comment thread lib/method/PACMethod_mosh.pm
Comment thread lib/PACKeyBindings.pm
Comment on lines +326 to +328
if ($uuid && $$hk{$uuid}{$window}{$keymask}) {
return (0, "<i>$keymask</i> already assigned to <b>hotkey</b>\n\n$$hk{$window}{$keymask}[2]");
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: When a duplicate connection-specific hotkey is detected, the error message incorrectly references the global hotkey data structure, causing a warning and data corruption.
Severity: MEDIUM

Suggested Fix

Update the error message on line 327 to reference the correct UUID-scoped hotkey data structure, $$hk{$uuid}{$window}{$keymask}[2], to display the correct information and prevent accessing an undefined value.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: lib/PACKeyBindings.pm#L326-L328

Potential issue: When checking for a duplicate connection-specific (UUID-scoped) hotkey,
the code correctly identifies the conflict using `$$hk{$uuid}{$window}{$keymask}`.
However, the subsequent error message incorrectly attempts to retrieve details from the
global hotkey data structure, `$$hk{$window}{$keymask}[2]`, which is undefined in this
context. This results in an uninitialized value warning, a misleading error message for
the user, and data structure corruption due to Perl's autovivification.

Comment thread lib/PACKeePass.pm
if ($$self{cfg}) {
$cfg = $$self{cfg};
} else {
$cfg = $self->get_cfg();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: A fatal error occurs when using KeePass substitution if the database file becomes inaccessible, as _hasCacheValue calls mtime on a undef value from stat('').
Severity: HIGH

Suggested Fix

Add a check in the _hasCacheValue function to ensure that $$cfg{database} is not empty and that the stat call returns a valid object before attempting to call the mtime method on it.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: lib/PACKeePass.pm#L848

Potential issue: The `_hasCacheValue` function attempts to get the modification time of
a KeePass database file using `stat($$cfg{database})->mtime`. If the database file is
deleted or moved after the application starts, `get_cfg()` sets `$$cfg{database}` to an
empty string. The subsequent call to `stat('')` returns `undef`, causing a fatal "Can't
call method 'mtime' on an undefined value" error when the application tries to perform a
KeePass field substitution.

Comment thread utils/pac2asbru.pl
Comment on lines +134 to +141
opendir($ss, "$new_dir/screenshots");
while (my $f = readdir($ss)) {
if ($f =~ /\.png/) {
my $n = $f;
$n =~ s/pac/asbru/;
system "$ENV{'ASBRU_ENV_FOR_EXTERNAL'} mv -f $new_dir/screenshots/$f $new_dir/screenshots/$n";
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The opendir call lacks an error check for a potentially missing screenshots directory, which will cause a runtime error when readdir is called on the resulting invalid handle.
Severity: HIGH

Suggested Fix

Check the return value of opendir. If the directory is successfully opened, execute the while loop to process its contents, and then call closedir($ss) after the loop to release the directory handle.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: utils/pac2asbru.pl#L134-L141

Potential issue: The script calls `opendir($ss, "$new_dir/screenshots")` without
validating the return value. If the `screenshots` directory does not exist, which is a
valid scenario for older installations being migrated, `opendir` returns false. The
subsequent `readdir($ss)` call on the invalid handle will then trigger a runtime error,
interrupting the migration process and potentially leaving the application configuration
in an inconsistent state. Additionally, the directory handle is not closed with
`closedir` after use.

Comment thread lib/PACKeePass.pm
Comment on lines +116 to 125
if ((!defined $file)||(-d $file)||(!-e $file)) {
return 0;
}
if (!-e $pathcli) {
$pathcli = '';
}
if ($$self{disable_keepassxc}) {
$$self{cfg}{use_keepass} = 0;
}
$$self{frame}{fcbKeePassFile}->set_filename($file);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Calling the update() method on a PACKeePass instance created with buildgui=0 will cause a crash because it attempts to access uninitialized GUI frame widgets.
Severity: HIGH

Suggested Fix

Add a guard condition at the beginning of the update() method to check if the GUI was built before attempting to access any frame widgets. For example, return unless ($$self{frame}); or return unless ($$self{buildgui});.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: lib/PACKeePass.pm#L116-L125

Potential issue: When a `PACKeePass` object is instantiated with `buildgui=0` (e.g., for
use in `PACTerminal` or `PACEdit`), the `$$self{frame}` attribute is not initialized.
However, the `update()` method unconditionally attempts to access GUI widgets within
this frame, such as `$$self{frame}{fcbKeePassFile}`. This dereferencing of an undefined
value will cause a fatal Perl error, crashing the application. This can occur when
`PACTerminal.pm` or `PACEdit.pm` call `update()` on a non-GUI `PACKeePass` object.

Comment on lines +845 to +855
}
}
});
push(@menu_items, {
label => 'KeePassX',
stockicon => 'pac-keepass',
submenu => [
{
label => 'KeePassX title values',
submenu => \@titles
}, {
label => 'KeePassX username values',
submenu => \@usernames
}, {
label => 'KeePassX URL values',
submenu => \@urls
}, {
label => "KeePass Extended Query",
tooltip => "This allows you to select the value to be returned, based on another value's match againt a Perl Regular Expression",
code => sub {$w{send}->insert_text("<KPXRE_GET_(title|username|password|url)_WHERE_(title|username|password|url)==Your_RegExp_here==>", -1, $w{send}->get_position);}
label => 'Add Password KeePassXC',
tooltip => 'KeePassXC Password',
code => sub {
my $pos = $w{send}->get_property('cursor_position');
my $selection = $PACMain::FUNCS{_KEEPASS}->listEntries($$self{_WINDOWEDIT});
if ($selection) {
$w{send}->insert_text("<password|$selection>", -1, $w{expect}->get_position);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The KeePassXC context menu for the 'Send' field incorrectly inserts text into the 'Expect' field's cursor position by using $w{expect}->get_position() instead of $w{send}->get_position().
Severity: MEDIUM

Suggested Fix

Update the insert_text calls in the KeePassXC username and password handlers to use the cursor position from the correct widget. Change $w{expect}->get_position() to $w{send}->get_position() on lines 844 and 855.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: lib/edit/PACExpectEntry.pm#L844-L855

Potential issue: In the 'Send' field's right-click menu, the handlers for inserting
KeePassXC username and password placeholders incorrectly use the cursor position from
the 'Expect' field (`$w{expect}`) instead of the 'Send' field (`$w{send}`). This causes
the placeholder text, like `<username|selection>`, to be inserted at the cursor's
location in the 'Expect' field, not the 'Send' field where the user initiated the
action. This behavior silently corrupts the user's configuration.

Comment thread lib/ex/PACTree.pm
Comment on lines +259 to +263
}
if ($$focus{uuid} eq $elem_uuid) {
$self->set_cursor($path, undef, 0);
return 1;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The _focusPrevious function can crash because $focus is dereferenced without being initialized if the target is the first element in the tree.
Severity: HIGH

Suggested Fix

Add a check to ensure the $focus variable is defined before it is dereferenced in the second loop. For example, wrap the dereference in a conditional like if (defined $focus) { ... }.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: lib/ex/PACTree.pm#L259-L263

Potential issue: In the `_focusPrevious` method, the `$focus` variable is initialized to
`undef`. If the target `uuid` is found on the first iteration of the initial loop, the
function proceeds to a second loop without ever assigning a value to `$focus`. This
second loop then unconditionally dereferences `$focus` (e.g., `$$focus{uuid}`), causing
a "Can't use an undefined value as a HASH reference" runtime crash. This occurs when a
user navigates up from the first item in a tree view.

Comment thread lib/method/PACMethod_sftp.pm
Code was not working on some specific versions of perl (at least with 5.38.2 shipped with Ubuntu 24.04).
Comment thread lib/method/PACMethod_ssh.pm
Comment thread lib/edit/PACTermOpts.pm
Comment thread lib/PACKeePass.pm
Comment on lines +425 to +429
if ($ok eq 'ok') {
my $selection = $w{window}{gui}{treelist}->get_selection();
my $model = $w{window}{gui}{treelist}->get_model();
my @paths = _getSelectedRows($selection);
$entry = $model->get_value($model->get_iter($paths[0]),0);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: In listEntries(), accessing $paths[0] without checking if the @paths array is empty causes a crash if a user clicks "ok" without selecting a KeePass entry.
Severity: HIGH

Suggested Fix

Add a guard clause to verify that the @paths array is not empty after the user interacts with the dialog. If it is empty, either do nothing or show a message, but do not proceed to access the first element.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: lib/PACKeePass.pm#L425-L429

Potential issue: The `listEntries()` function in `lib/PACKeePass.pm` displays a dialog
for KeePass entry selection. If a user clicks the "ok" button without selecting an entry
from the list, the `@paths` array will be empty. The code then attempts to access
`$paths[0]`, which evaluates to `undef`. This `undef` value is passed to
`$model->get_iter()`, leading to a fatal runtime crash when `$model->get_value()` is
called on the resulting invalid iterator. The same vulnerability exists in the
`row_activated` callback.

Comment thread lib/PACKeyBindings.pm
Comment on lines +90 to +92
my $shift = $state * ['shift-mask'] ? 'Shift' : '';
my $ctrl = $state * ['control-mask'] ? 'Ctrl' : '';
my $alt = $state * ['mod1-mask'] ? 'Alt' : '';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The code in GetKeyMask uses multiplication instead of a bitwise AND to check for modifier keys, which will cause modifier key detection to fail.
Severity: HIGH

Suggested Fix

Replace the multiplication operation with a bitwise AND (&) and use the appropriate Gdk::ModifierType constants (e.g., Gdk::ModifierType::SHIFT_MASK) to correctly check for active modifier keys in the $state variable.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: lib/PACKeyBindings.pm#L90-L92

Potential issue: In the new `PACKeyBindings.pm` file, the `GetKeyMask` method
incorrectly checks for modifier keys like Shift, Ctrl, and Alt. It uses multiplication
with an array reference (e.g., `$state * ['shift-mask']`) instead of the correct bitwise
AND operation (e.g., `$state & Gdk::ModifierType::SHIFT_MASK`). This logical error will
cause the detection of all modifier keys to fail, effectively breaking any keybindings
that rely on them.

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

Labels

⤵️ pull merge-conflict Resolve conflicts manually

Projects

None yet

Development

Successfully merging this pull request may close these issues.