Skip to content

Commit

Permalink
MSI raise error if password contains semicolon (#32624)
Browse files Browse the repository at this point in the history
  • Loading branch information
clarkb7 authored Jan 8, 2025
1 parent 832149a commit d76f9c9
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
enhancements:
- |
The Windows Agent MSI now shows the user an error message
if the provided password contains a semicolon.
Original file line number Diff line number Diff line change
Expand Up @@ -165,5 +165,19 @@ public void ProcessDdAgentUserCredentials_With_Local_System_And_Current_User_Loc
.Contain(kvp => kvp.Key == "DDAGENTUSER_RESET_PASSWORD" && string.IsNullOrEmpty(kvp.Value)).And
.Contain(kvp => kvp.Key == "DDAGENTUSER_PROCESSED_PASSWORD" && string.IsNullOrEmpty(kvp.Value));
}

[Fact]
public void ProcessDdAgentUserCredentials_Catch_Semicolon_In_Password()
{
Test.Session
.Setup(session => session["DDAGENTUSER_NAME"]).Returns("ddagentuser");
Test.Session
.Setup(session => session["DDAGENTUSER_PASSWORD"]).Returns("password;123");

Test.Create()
.ProcessDdAgentUserCredentials()
.Should()
.Be(ActionResult.Failure);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,10 @@ public ActionResult ProcessDdAgentUserCredentials(bool calledFromUIControl = fal
_session.Log("Ignoring provided password because account is a service account");
ddAgentUserPassword = null;
}
else if (!string.IsNullOrEmpty(ddAgentUserPassword))
{
TestValidAgentUserPassword(ddAgentUserPassword);
}

_session["DDAGENTUSER_PROCESSED_PASSWORD"] = ddAgentUserPassword;
}
Expand All @@ -526,6 +530,17 @@ public ActionResult ProcessDdAgentUserCredentials(bool calledFromUIControl = fal
return ActionResult.Success;
}

private void TestValidAgentUserPassword(string ddAgentUserPassword)
{
// password cannot contain semicolon
// semicolon is the delimiter for CustomActionData, and we don't have special handling for this.
// TODO: WINA-1226
if (ddAgentUserPassword.Contains(";"))
{
throw new InvalidAgentUserConfigurationException("The password provided contains an invalid character. Please provide a password that does not contain a semicolon.");
}
}

public static ActionResult ProcessDdAgentUserCredentials(Session session)
{
return new ProcessUserCustomActions(new SessionWrapper(session)).ProcessDdAgentUserCredentials(
Expand Down

0 comments on commit d76f9c9

Please sign in to comment.