Skip to content

Delete instance.go #89

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

Merged
merged 11 commits into from
Jan 17, 2025
Merged

Delete instance.go #89

merged 11 commits into from
Jan 17, 2025

Conversation

phbnf
Copy link
Collaborator

@phbnf phbnf commented Jan 15, 2025

Towards #5

This PR reorganizes the SCTFE code. It deletes instance.go, and migrate its content into:

  • main.go for everything related to setting up the log. Later PR will move some of this into the sctfe library.
  • config.go for everything related to CT log server logic.
  • handlers.go for everything related to http serving.

It's a stepping stone, more simplifications are to come afterwards (private/public objets and libraries, file renamed, better structures, etc.). To start with, my goal is to architecture the code around three building blocks:

  • CT server logic: provides all the underlying storage and SCT apis
  • cert-validation: validate the input chains based on cert expiry, roots, oid, etc.
  • HTTP server logic: bridge between end users and the CT server logic

@phbnf phbnf requested a review from AlCutter January 15, 2025 13:34
@phbnf phbnf requested a review from roger2hk January 15, 2025 13:36
@phbnf phbnf marked this pull request as ready for review January 15, 2025 13:36
Copy link
Collaborator

@AlCutter AlCutter left a comment

Choose a reason for hiding this comment

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

Just a few tiny nits/suggestions.

cmd/gcp/main.go Outdated
signer, err := NewSecretManagerSigner(ctx, *signerPublicKeySecretName, *signerPrivateKeySecretName)
if err != nil {
klog.Exitf("Can't create secret manager signer: %v", err)
}
cpSigner, err := sctfe.NewCpSigner(signer, *origin, timeSource)
if err != nil {
klog.Exitf("failed to create checkpoint Signer: %v", err)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: "Failed..."

cmd/gcp/main.go Outdated

storage, err := newGCPStorage(ctx, cpSigner)
if err != nil {
klog.Exitf("failed to initiate storage backend: %v", err)
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: "Failed...

cmd/gcp/main.go Outdated
Validated: vCfg,
Deadline: *httpDeadline,
MetricFactory: prometheus.MetricFactory{},
RequestLog: new(sctfe.DefaultRequestLog),
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: match style for MetricFactory:

Suggested change
RequestLog: new(sctfe.DefaultRequestLog),
RequestLog: &sctfe.DefaultRequestLog{},

config.go Outdated

// Validate signer that only ECDSA is supported.
// TODO(phboneff): if this is a library this should also allow RSA as per RFC6962.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Devil's avocado: if it supports ECDSA then that's enough to build RFC6962-compliant logs; there's no requirement to support RSA (or, would we recommend anyone to use RSA for a new log, these days?)

config.go Outdated
if rejectExtensions != "" {
lRejectExtensions = strings.Split(rejectExtensions, ",")
if rejectExpired && rejectUnexpired {
return nil, errors.New("rejecting all certificates")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
return nil, errors.New("rejecting all certificates")
return nil, errors.New("configuration would reject all certificates")

config.go Outdated
Signer: signer,
// Validate the time interval.
if notAfterStart != nil && notAfterLimit != nil && (notAfterLimit).Before(*notAfterStart) {
return nil, errors.New("limit before start")
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: worth doing fmt.Errorf with the dates in?

config.go Outdated
Signer: signer,
// Validate the time interval.
if notAfterStart != nil && notAfterLimit != nil && (notAfterLimit).Before(*notAfterStart) {
return nil, fmt.Errorf("not_after limit %q before start %q", notAfterLimit.Format(time.RFC3339), notAfterStart.Format(time.RFC3339))
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return nil, fmt.Errorf("not_after limit %q before start %q", notAfterLimit.Format(time.RFC3339), notAfterStart.Format(time.RFC3339))
return nil, fmt.Errorf("not_after_limit %q before not_after_start %q", notAfterLimit.Format(time.RFC3339), notAfterStart.Format(time.RFC3339))

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I had done this on purpose to allow for shorter messages, and not to mention the flag there since they belong in main.go. As a compromise to address your comment, I changed "not_after" to "'Not After'", thus matching the common name of this field on certificates.

@phbnf phbnf merged commit 903d753 into transparency-dev:main Jan 17, 2025
7 checks passed
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.

3 participants