10000 feat: add all missing security records to write ops by polillomm · Pull Request #184 · goinfinite/os · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat: add all missing security records to write ops #184

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

Conversation

polillomm
Copy link
Member

No description provided.

…opagate error validation to routers and throw fatal when controller is not initialized
With the addition of OperatorAccountId and OperatorIpAddress, many repositories, use cases, and other components were impacted. Some required quick restructuring, like creating new DTOs to make this change without compromising code readability, as the visible increase in complexity could have been problematic without these new DTOs.

It's worth noting that only some methods received new DTOs, not all. This is due to a lack of context for creating new DTOs, as well as dependency injections that can significantly increase the number of parameters passed to a function.
Copy link
Member Author
@polillomm polillomm left a comment

Choose a reason for hiding this comment

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

Dev review ok.

Comment on lines 6 to 7
PrimaryVirtualHost valueObject.Fqdn `json:"primaryVirtualHost"`
Hostname valueObject.Fqdn `json:"hostname"`
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the difference between those two? If Primary is suppose to be the parent of the Hostname than the naming of Hostname should be more clear. Hostname by itself is way too generic.

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually, the PrimaryVirtualHost serves as the injection of the primary vhost itself into the UC to compare the hostname to be removed with the primary vhost, precisely to prevent users from removing the primary vhost.

To avoid misunderstandings, I moved this property below the Hostname, and removed its JSON tag, similar to what was done with the operators.

"github.com/goinfinite/os/src/domain/valueObject"
)

type ReplaceWithValidSsl struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

ReplaceWithValidSsl isn't an UpdateSslPair why?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because this DTO is used by the method that replaces the invalid certificate with a self-signed certificate. It's the same method used by the watchdog. Changing it to UpdateSslPair doesn’t make sense, as its purpose is not to update the SslPair data but to inform the repository method which SslPair is being replaced.

trashPath, _ := valueObject.NewUnixFilePath(TrashDirPath)
err := uc.filesCmdRepo.Delete(trashPath)
if err != nil {
return err
}

return uc.CreateTrash()
return uc.CreateTrash(operatorAccountId, operatorIpAddress)
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't CreateTrash have a DTO and request which accountId do you want to have the trash created? I can't recall if the TrashDir is based on account or if it's a general thing. The name CreateTrash doesn't tell me if it's a GeneralTrash or if it's a AccountTrash.

Copy link
Member Author
@polillomm polillomm Nov 27, 2024

Choose a reason for hiding this comment

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

I believe it's unnecessary to create separate trash dirs for each account, let alone a DTO, since everything is handled within the method itself. You only need to provide the operator infos.

"golang.org/x/crypto/sha3"
)

func TransformPlainContentIntoStrongHash(
Copy link
Contributor

Choose a reason for hiding this comment

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

What PlainContent even means? Isn't this a regular hasher?

}
contentToEncode := sslCertificate.String() + "\n" + sslChainCertificatesMerged + "\n" + sslPrivateKey.String()

sslPairIdContent, err := voHelper.TransformPlainContentIntoStrongHash(contentToEncode)
Copy link
Contributor

Choose a reason for hiding this comment

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

Ahá, PlainContent means nothing indeed. It's just a string. The helper should be called StrongStringHasher or something like that. No need to create mystery on the code.

operatorAccountId := service.LocalOperatorAccountId
if requestBody["operatorAccountId"] != nil {
operatorAccountId, err = valueObject.NewAccountId(
requestBody["operatorAccountId"],
Copy link
Contributor

Choose a reason for hiding this comment

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

Wait, what? Are you allowing the user to send the operatorAccountId? Cause that would be a magnificent security flaw.

Copy link
Member Author
@polillomm polillomm left a comment

Choose a reason for hiding this comment

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

Dev review ok.

@ntorga ntorga merged commit 594c75b into goinfinite:main Nov 27, 2024
@polillomm polillomm deleted the feat/add-all-missing-security-records-to-write-ops branch November 28, 2024 13:51
polillomm added a commit to polillomm/os that referenced this pull request Nov 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0