You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Feb 15, 2024. It is now read-only.
While preparing to duplicate an existing validation check like this one the thought hit me: Maybe it's not necessary to guard against empty strings as an input value from a user? It feels "wrong", but perhaps the config packages already have this responsibility?
// Verify that the user did not opt to set an empty string as the value,// otherwise we fail the config validation by returning an error.ifc.IsSetIgnoredIPAddressesFile() &&c.IgnoredIPAddressesFile() =="" {
returnfmt.Errorf("empty path to ignored ip addresses file provided")
}
For now I'm going ahead with duplicating the validation check, but it would be good to learn what the best practice for this is and apply it here (and elsewhere).
The text was updated successfully, but these errors were encountered:
Not sure if it makes the specific difference here, but in our case the validation check is performed specifically for filenames used by the application. The example method given previously alters the behavior of the application depending on its contents, so maybe more validation is required there vs what log file to write where.
However, even that setting makes a difference; fail2ban is configured to look for a log file in a very specific location which is intended to match the location that brick is configured to write to.
Perhaps this is more a case of failing to properly document intentions than anything else.
This simpler empty string check made not far above the example seems to cover both cases:
ifc.ReportedUsersLogFile() =="" {
returnfmt.Errorf("path to reported users log file not provided")
}
Because we have default values assigned, you would only ever see an empty string at this point if the user explicitly provided it (and any config-handling packages didn't object first). If we have a default that the Config.IgnoredUsersFile() method returns, we would only get an empty string if (again), the user explicitly provides it. I'm now thinking that providing an IsSetXYZ() type of validation helper method isn't necessary because we're testing the final results and ensuring that empty strings aren't passed on to the rest of the application.
While preparing to duplicate an existing validation check like this one the thought hit me: Maybe it's not necessary to guard against empty strings as an input value from a user? It feels "wrong", but perhaps the config packages already have this responsibility?
For now I'm going ahead with duplicating the validation check, but it would be good to learn what the best practice for this is and apply it here (and elsewhere).
The text was updated successfully, but these errors were encountered: