mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-11-25 03:13:49 +00:00
Added a check for the characters of ERI usernames, tokens, and passwords (#1228)
This commit is contained in:
1 parent
e5a7f5423f
commit
9b4d07552d
16 files changed
+988
-21
No files matched your search
@@ -326,6 +326,19 @@ public record struct DataSourceERI_V1: IERIDataSource
|
||||
LOGGER.LogWarning($"The configured data source {idx} must specify a username. (Plugin ID: {configPluginId})");
|
||||
return false;
|
||||
}
|
||||
|
||||
//
|
||||
// The username goes to the ERI server in an HTTP header, which carries nothing but ASCII.
|
||||
// Nobody on the device could change it, so the data source would fail with every search:
|
||||
//
|
||||
var usernameIssue = ERICredentialValidation.CheckUsername(username);
|
||||
if (usernameIssue.IsProblem)
|
||||
{
|
||||
LOGGER.LogWarning($"The username of the configured data source {idx} contains a character which the ERI server cannot receive ({usernameIssue.Kind}). (Plugin ID: {configPluginId})");
|
||||
return false;
|
||||
}
|
||||
|
||||
username = ERICredentialValidation.Normalize(username);
|
||||
}
|
||||
|
||||
dataSource = new DataSourceERI_V1
|
||||
@@ -451,6 +464,18 @@ public record struct DataSourceERI_V1: IERIDataSource
|
||||
return false;
|
||||
}
|
||||
|
||||
//
|
||||
// The secret goes to the ERI server in an HTTP header, as the username does. One which the
|
||||
// header cannot carry counts like one which cannot be decrypted. A dry run checks it as well,
|
||||
// so that it writes the warning, too:
|
||||
//
|
||||
var secretIssue = ERICredentialValidation.CheckSecret(dataSource.AuthMethod, decryptedSecret);
|
||||
if (secretIssue.IsProblem)
|
||||
{
|
||||
LOGGER.LogWarning($"The {secretFieldName} for data source {idx} contains a character which the ERI server cannot receive ({secretIssue.Kind}). (Plugin ID: {configPluginId})");
|
||||
return false;
|
||||
}
|
||||
|
||||
//
|
||||
// A dry run only checks the configuration, so it queues nothing: the start which follows it
|
||||
// would otherwise store the secret once more for every dry run before it:
|
||||
@@ -461,7 +486,7 @@ public record struct DataSourceERI_V1: IERIDataSource
|
||||
PendingEnterpriseSecrets.Add(new(
|
||||
$"{ISecretId.ENTERPRISE_KEY_PREFIX}::{dataSource.Id}",
|
||||
dataSource.Name,
|
||||
decryptedSecret,
|
||||
ERICredentialValidation.Normalize(decryptedSecret),
|
||||
SecretStoreType.DATA_SOURCE));
|
||||
LOGGER.LogDebug($"Successfully decrypted the {secretFieldName} for data source {idx}. It will be stored in the OS keyring. (Plugin ID: {configPluginId})");
|
||||
return true;
|
||||
|
||||
Reference in new issue
Block a user