Skip to content
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

Issue 747 fix #777

Merged
merged 3 commits into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
foreach (var cursor in cursors.Where(c => !string.IsNullOrWhiteSpace(c)))
{
success &= registry.TryRead(RegistryValue.UserHive.Cursors_Key, cursor, out var value);
success &= value == default || !(value is string) || (value is string path && (string.IsNullOrWhiteSpace(path) || IsValidCursorPath(path)));
success &= !(value is string) || (value is string path && (string.IsNullOrWhiteSpace(path) || IsValidCursorPath(path)));

Check warning on line 80 in SafeExamBrowser.Runtime/Operations/SessionIntegrityOperation.cs

View check run for this annotation

Codecov / codecov/patch

SafeExamBrowser.Runtime/Operations/SessionIntegrityOperation.cs#L80

Added line #L80 was not covered by tests

if (!success)
{
Expand Down Expand Up @@ -113,7 +113,7 @@

if (registry.TryRead(RegistryValue.MachineHive.EaseOfAccess_Key, RegistryValue.MachineHive.EaseOfAccess_Name, out var value))
{
if (value == default || (value is string s && string.IsNullOrWhiteSpace(s)))
if (value is string s && string.IsNullOrWhiteSpace(s))
{
success = true;
logger.Info("Ease of access configuration successfully verified.");
Expand All @@ -135,7 +135,8 @@
}
else
{
logger.Error("Failed to verify ease of access configuration!");
success = true;
logger.Info("Ease of access configuration successfully verified (value does not exist).");

Check warning on line 139 in SafeExamBrowser.Runtime/Operations/SessionIntegrityOperation.cs

View check run for this annotation

Codecov / codecov/patch

SafeExamBrowser.Runtime/Operations/SessionIntegrityOperation.cs#L138-L139

Added lines #L138 - L139 were not covered by tests
}

return success;
Expand Down
9 changes: 4 additions & 5 deletions SafeExamBrowser.SystemComponents/Registry/Registry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,21 +73,20 @@

public bool TryRead(string key, string name, out object value)
{
var success = false;

var defaultValue = new object();
value = default;

try
{
value = Microsoft.Win32.Registry.GetValue(key, name, default);
success = true;
value = Microsoft.Win32.Registry.GetValue(key, name, defaultValue);
}
catch (Exception e)
{
logger.Error($"Failed to read value '{name}' from registry key '{key}'!", e);
}

return success;
return value != default && value != defaultValue;
Fixed Show fixed Hide fixed
}

public bool TryGetNames(string keyName, out IEnumerable<string> names)
Expand Down