Skip to content

Commit

Permalink
Fix v2 with go.mod (zmap#398)
Browse files Browse the repository at this point in the history
zmap#398

Adopt the **Major Subdirectory** approach from
https://github.com/golang/go/wiki/Modules#releasing-modules-v2-or-higher

### Effects:

* Moves all code into a `v2` subdirectory. Consumers of ZLint v2 will need to change their imports in go to `github.com/zmap/zlint/v2` and update `go.mod` accordingly.
* Old versions of ZLint are still fetchable via `go.mod` and version pinning, e.g. `require github.com/zmap/[email protected]`
* People using `go get` without modules are going to have all their code break. However, this was going to happen regardless of what we do with our directories because we made breaking changes to our code.

### Patching old versions

To patch an old version (pre-2.0), we would need to branch off of one of the old tags. To avoid this, we could attempt to maintain support for 1.1.0 by implementing another point release at the top-level directory on top of `v2`, and then exposing the old API's above the v2 directory (see https://github.com/rsc/quote/blob/master/quote.go as an example). However, I don't believe we plan on supporting old versions at all, so there's no reason to do this. On the off chance we do need to cut a point release for 1.1.0, we can use Git.

### Why not use the Major Branch approach

When not maintaining support for v1 side-by-side with v2, the major branch approach is identical to the Major Subdirectory approach from a Git standpoint---point release for v1 would need to be done on branches. However, it does then have the side effect that the import path for your code no longer matches the directory structure of your code. Effectively, we could `mv` all of the `v2` directory back up to the top-level, claim the name `...v2/`, and use `v2` in all of our import paths. While this might look cleaner from a Git repo standpoint, my gut sense is that we may as well match the directories to the import path, since that's slightly easier to grok.
  • Loading branch information
dadrian committed Feb 13, 2020
1 parent 53441bd commit fd40f57
Show file tree
Hide file tree
Showing 1,554 changed files with 1,053 additions and 1,051 deletions.
10 changes: 5 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,13 @@ _testmain.go
0

### Build Targets ###
/zlint
cmd/zlint/zlint
/zlint-gtld-update
cmd/zlint-gtld-update/zlint-gtld-update
v2/zlint
v2/cmd/zlint/zlint
v2/zlint-gtld-update
v2/cmd/zlint-gtld-update/zlint-gtld-update

### Integration test data ###
data
v2/data

### Goreleaser builds ###
dist
1 change: 1 addition & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ before:
- go mod tidy
builds:
-
dir: v2
main: ./cmd/zlint/main.go
binary: zlint
env:
Expand Down
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ install:
script:
# Fast-fail on non-zero exit codes
- set -e
- cd v2
# Build commands
- make
# Verify that all files pass the golangci-lint code lints
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ command-line certificate parser that links against ZLint.

Example ZLint CLI usage:

go get github.com/zmap/zlint/cmd/zlint
go get github.com/zmap/zlint/v2/cmd/zlint
echo "Lint mycert.pem with all applicable lints"
zlint mycert.pem

Expand All @@ -100,7 +100,7 @@ lints is as simple as using `zlint.LintCertificate` with a parsed certificate:
```go
import (
"github.com/zmap/zcrypto/x509"
"github.com/zmap/zlint"
"github.com/zmap/zlint/v2"
)

var certDER []byte = ...
Expand All @@ -114,8 +114,8 @@ name) filter the global lint registry and use it with `zlint.LintCertificateEx`:
```go
import (
"github.com/zmap/zcrypto/x509"
"github.com/zmap/zlint"
"github.com/zmap/zlint/lint"
"github.com/zmap/zlint/v2"
"github.com/zmap/zlint/v2/lint"
)

var certDER []byte = ...
Expand All @@ -129,7 +129,7 @@ zlintResultSet := zlint.LintCertificateEx(parsed, registry)

See [the `zlint` command][zlint cmd]'s source code for an example.

[zlint cmd]: https://github.com/zmap/zlint/blob/master/cmd/zlint/main.go
[zlint cmd]: https://github.com/zmap/zlint/blob/master/v2/cmd/zlint/main.go


Extending ZLint
Expand Down
2 changes: 1 addition & 1 deletion benchmarks_test.go → v2/benchmarks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"testing"

"github.com/zmap/zcrypto/x509"
"github.com/zmap/zlint/lint"
"github.com/zmap/zlint/v2/lint"
)

var (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
"time"

log "github.com/sirupsen/logrus"
"github.com/zmap/zlint/util"
"github.com/zmap/zlint/v2/util"
)

const (
Expand Down
4 changes: 2 additions & 2 deletions cmd/zlint/main.go → v2/cmd/zlint/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ import (

log "github.com/sirupsen/logrus"
"github.com/zmap/zcrypto/x509"
"github.com/zmap/zlint"
"github.com/zmap/zlint/lint"
"github.com/zmap/zlint/v2"
"github.com/zmap/zlint/v2/lint"
)

var ( // flags
Expand Down
2 changes: 1 addition & 1 deletion go.mod → v2/go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/zmap/zlint
module github.com/zmap/zlint/v2

require (
github.com/sirupsen/logrus v1.3.0
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions integration/corpus_test.go → v2/integration/corpus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
"sync"
"testing"

"github.com/zmap/zlint"
"github.com/zmap/zlint/lint"
"github.com/zmap/zlint/v2"
"github.com/zmap/zlint/v2/lint"
)

// lintCertificate lints the provided work item's certificate to produce
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"regexp"
"testing"

"github.com/zmap/zlint/lint"
"github.com/zmap/zlint/v2/lint"
)

var (
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion integration/result.go → v2/integration/result.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package integration
import (
"fmt"

"github.com/zmap/zlint/lint"
"github.com/zmap/zlint/v2/lint"
)

type resultCount struct {
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion lint/base.go → v2/lint/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"time"

"github.com/zmap/zcrypto/x509"
"github.com/zmap/zlint/util"
"github.com/zmap/zlint/v2/util"
)

// LintInterface is implemented by each Lint.
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import (

"github.com/zmap/zcrypto/x509"
"github.com/zmap/zcrypto/x509/ct"
"github.com/zmap/zlint/lint"
"github.com/zmap/zlint/util"
"github.com/zmap/zlint/v2/lint"
"github.com/zmap/zlint/v2/util"
)

type sctPolicyCount struct{}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ package apple
import (
"testing"

"github.com/zmap/zlint/lint"
"github.com/zmap/zlint/test"
"github.com/zmap/zlint/v2/lint"
"github.com/zmap/zlint/v2/test"
)

func TestSCTCountPolicyUnsatisified(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ package cabf_br

import (
"github.com/zmap/zcrypto/x509"
"github.com/zmap/zlint/lint"
"github.com/zmap/zlint/util"
"github.com/zmap/zlint/v2/lint"
"github.com/zmap/zlint/v2/util"
)

type caCommonNameMissing struct{}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ package cabf_br
import (
"testing"

"github.com/zmap/zlint/lint"
"github.com/zmap/zlint/test"
"github.com/zmap/zlint/v2/lint"
"github.com/zmap/zlint/v2/test"
)

func TestCaCommonNameMissing(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ package cabf_br

import (
"github.com/zmap/zcrypto/x509"
"github.com/zmap/zlint/lint"
"github.com/zmap/zlint/util"
"github.com/zmap/zlint/v2/lint"
"github.com/zmap/zlint/v2/util"
)

/************************************************
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ package cabf_br
import (
"testing"

"github.com/zmap/zlint/lint"
"github.com/zmap/zlint/test"
"github.com/zmap/zlint/v2/lint"
"github.com/zmap/zlint/v2/test"
)

func TestCaCountryNameInvalid(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ package cabf_br

import (
"github.com/zmap/zcrypto/x509"
"github.com/zmap/zlint/lint"
"github.com/zmap/zlint/util"
"github.com/zmap/zlint/v2/lint"
"github.com/zmap/zlint/v2/util"
)

/************************************************
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ package cabf_br
import (
"testing"

"github.com/zmap/zlint/lint"
"github.com/zmap/zlint/test"
"github.com/zmap/zlint/v2/lint"
"github.com/zmap/zlint/v2/test"
)

/************************************************
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ package cabf_br

import (
"github.com/zmap/zcrypto/x509"
"github.com/zmap/zlint/lint"
"github.com/zmap/zlint/util"
"github.com/zmap/zlint/v2/lint"
"github.com/zmap/zlint/v2/util"
)

/************************************************
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ package cabf_br
import (
"testing"

"github.com/zmap/zlint/lint"
"github.com/zmap/zlint/test"
"github.com/zmap/zlint/v2/lint"
"github.com/zmap/zlint/v2/test"
)

func TestCaKeyUsageNoCRLSign(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ If the Root CA Private Key is used for signing OCSP responses, then the digitalS

import (
"github.com/zmap/zcrypto/x509"
"github.com/zmap/zlint/lint"
"github.com/zmap/zlint/util"
"github.com/zmap/zlint/v2/lint"
"github.com/zmap/zlint/v2/util"
)

type caDigSignNotSet struct{}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ package cabf_br
import (
"testing"

"github.com/zmap/zlint/lint"
"github.com/zmap/zlint/test"
"github.com/zmap/zlint/v2/lint"
"github.com/zmap/zlint/v2/test"
)

func TestCaKeyUsageNoDigSign(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import (
"encoding/asn1"

"github.com/zmap/zcrypto/x509"
"github.com/zmap/zlint/lint"
"github.com/zmap/zlint/util"
"github.com/zmap/zlint/v2/lint"
"github.com/zmap/zlint/v2/util"
)

type caIsCA struct{}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ package cabf_br
import (
"testing"

"github.com/zmap/zlint/lint"
"github.com/zmap/zlint/test"
"github.com/zmap/zlint/v2/lint"
"github.com/zmap/zlint/v2/test"
)

func TestKeyCertSignNotCA(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ If the Root CA Private Key is used for signing OCSP responses, then the digitalS

import (
"github.com/zmap/zcrypto/x509"
"github.com/zmap/zlint/lint"
"github.com/zmap/zlint/util"
"github.com/zmap/zlint/v2/lint"
"github.com/zmap/zlint/v2/util"
)

type caKeyCertSignNotSet struct{}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ package cabf_br
import (
"testing"

"github.com/zmap/zlint/lint"
"github.com/zmap/zlint/test"
"github.com/zmap/zlint/v2/lint"
"github.com/zmap/zlint/v2/test"
)

func TestCaKeyUsageNoCertSign(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ Conforming CAs MUST include this extension in certificates that

import (
"github.com/zmap/zcrypto/x509"
"github.com/zmap/zlint/lint"
"github.com/zmap/zlint/util"
"github.com/zmap/zlint/v2/lint"
"github.com/zmap/zlint/v2/util"
)

type caKeyUsageMissing struct{}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ package cabf_br
import (
"testing"

"github.com/zmap/zlint/lint"
"github.com/zmap/zlint/test"
"github.com/zmap/zlint/v2/lint"
"github.com/zmap/zlint/v2/test"
)

func TestCaKeyUsageMissing(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ If the Root CA Private Key is used for signing OCSP responses, then the digitalS

import (
"github.com/zmap/zcrypto/x509"
"github.com/zmap/zlint/lint"
"github.com/zmap/zlint/util"
"github.com/zmap/zlint/v2/lint"
"github.com/zmap/zlint/v2/util"
)

type caKeyUsageNotCrit struct{}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ package cabf_br
import (
"testing"

"github.com/zmap/zlint/lint"
"github.com/zmap/zlint/test"
"github.com/zmap/zlint/v2/lint"
"github.com/zmap/zlint/v2/test"
)

func TestCaKeyUsageNotCrit(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ The Certificate Subject MUST contain the following: organizationName (OID 2.5.4.

import (
"github.com/zmap/zcrypto/x509"
"github.com/zmap/zlint/lint"
"github.com/zmap/zlint/util"
"github.com/zmap/zlint/v2/lint"
"github.com/zmap/zlint/v2/util"
)

type caOrganizationNameMissing struct{}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ package cabf_br
import (
"testing"

"github.com/zmap/zlint/lint"
"github.com/zmap/zlint/test"
"github.com/zmap/zlint/v2/lint"
"github.com/zmap/zlint/v2/test"
)

func TestCAOrgNameBlank(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ package cabf_br

import (
"github.com/zmap/zcrypto/x509"
"github.com/zmap/zlint/lint"
"github.com/zmap/zlint/util"
"github.com/zmap/zlint/v2/lint"
"github.com/zmap/zlint/v2/util"
)

type certPolicyConflictsWithLocality struct{}
Expand Down
Loading

0 comments on commit fd40f57

Please sign in to comment.