Skip to content

Commit

Permalink
Change the license to apache-2.0 (#68)
Browse files Browse the repository at this point in the history
Signed-off-by: Gregory Schofield <[email protected]>
  • Loading branch information
gscho authored Apr 11, 2024
1 parent 5827a2b commit b447741
Show file tree
Hide file tree
Showing 17 changed files with 33 additions and 311 deletions.
8 changes: 0 additions & 8 deletions .github/workflows/build-and-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -275,14 +275,6 @@ jobs:
"v${{ steps.get-version.outputs.VERSION }}" \
"gemfast-${{ steps.get-version.outputs.VERSION }}-amd64.deb" \
"gemfast-${{ steps.get-version.outputs.VERSION }}-checksums.txt"
- uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
prerelease: false
title: "${{ steps.get-version.outputs.VERSION }}"
files: |
*.deb
*.txt
cleanup:
runs-on: ubuntu-latest
Expand Down
93 changes: 0 additions & 93 deletions LICENSE

This file was deleted.

23 changes: 14 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Gemfast has the following unique benefits:
* There is no need to install/upgrade/manage a version of Ruby on the server
* Go is generally faster and requires less memory then Ruby (still :heart: Ruby though)
* There are no external server dependencies like postgres, redis or memcached
* Gemfast can allow/deny gems based on CVE severity or a regex list (license version only)
* Gemfast can allow/deny gems based on CVE severity or a regex list

## Installing

Expand Down Expand Up @@ -51,15 +51,11 @@ When running Gemfast as a container, its important to mount the following direct
* /etc/gemfast - The directory for the gemfast.hcl config file
* /var/gemfast - The directory for the Gemfast data including gems and database

If using a licensed version of gemfast, also mount:
* /etc/machine-id - Used when registering a license key

```bash
docker run -d --name gemfast-server \
-p 2020:2020 \
-v /etc/gemfast:/etc/gemfast \
-v /var/gemfast:/var/gemfast \
-v /etc/machine-id:/etc/machine-id \
ghcr.io/gemfast/server:latest
```

Expand Down Expand Up @@ -94,9 +90,18 @@ ui_disabled = true

## License

Gemfast is source available software licensed under the Elastic License 2.0 (ELv2) License. The license restricts users from:
Gemfast is open source software licensed under the Apache 2.0 License.

```text
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
* Providing the software to third parties as a hosted or managed service
* Circumventing the license key functionality
http://www.apache.org/licenses/LICENSE-2.0
Users who purchase a license key will get access to all Gemfast features, support from the Gemfast creator and a commercial friendly license.
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License..
```
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.11.4
1.0.0
12 changes: 2 additions & 10 deletions cmd/gemfast-server/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"github.com/gemfast/server/internal/db"
"github.com/gemfast/server/internal/filter"
"github.com/gemfast/server/internal/indexer"
"github.com/gemfast/server/internal/license"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
)
Expand All @@ -30,12 +29,6 @@ func init() {
func start() {
// Load the config
cfg := config.NewConfig()

// Load the license
license, err := license.NewLicense(cfg)
if err != nil {
log.Warn().Err(err).Msg("failed to load license")
}
log.Info().Msg("starting services")

// Connect to the database
Expand All @@ -45,7 +38,6 @@ func start() {
}
database.Open()
defer database.Close()
database.SaveLicense(license)

// Start the indexer
indexer, err := indexer.NewIndexer(cfg, database)
Expand All @@ -58,10 +50,10 @@ func start() {
}

// Create the filter
f := filter.NewFilter(cfg, license)
f := filter.NewFilter(cfg)

// Start the advisory DB updater
advisoryDB := cve.NewGemAdvisoryDB(cfg, license)
advisoryDB := cve.NewGemAdvisoryDB(cfg)
err = advisoryDB.Refresh()
if err != nil {
log.Warn().Err(err).Msg("failed to refresh advisory DB")
Expand Down
1 change: 0 additions & 1 deletion internal/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,6 @@ func (api *API) configureUI(ui *ui.UI, uiPath *gin.RouterGroup) {
uiPath.POST("/upload", api.rubygemsHandler.geminaboxUploadGem)
uiPath.GET("/download/:gem", api.rubygemsHandler.localGemHandler)
uiPath.GET("/tokens", ui.AccessTokens)
uiPath.GET("/license", ui.License)
uiPath.POST("/gems/search", ui.SearchGems)
uiPath.GET("/gems/:source/prefix", ui.GemsByPrefix)
uiPath.GET("/gems/:source/prefix/:prefix", ui.GemsData)
Expand Down
9 changes: 2 additions & 7 deletions internal/api/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"github.com/gemfast/server/internal/db"
"github.com/gemfast/server/internal/filter"
"github.com/gemfast/server/internal/indexer"
"github.com/gemfast/server/internal/license"
"github.com/stretchr/testify/suite"
bolt "go.etcd.io/bbolt"
)
Expand Down Expand Up @@ -55,17 +54,13 @@ func (suite *APITestSuite) SetupTest() {
}

func createTestAPI(testDB *bolt.DB, cfg *config.Config) (*API, error) {
l, err := license.NewLicense(cfg)
if err != nil {
return nil, err
}
database := db.NewTestDB(testDB, cfg)
indexer, err := indexer.NewIndexer(cfg, database)
if err != nil {
return nil, fmt.Errorf("failed to create indexer: %w", err)
}
f := filter.NewFilter(cfg, l)
gdb := cve.NewGemAdvisoryDB(cfg, l)
f := filter.NewFilter(cfg)
gdb := cve.NewGemAdvisoryDB(cfg)
apiV1Handler := NewAPIV1Handler(cfg, database, indexer, f, gdb)
rubygemsHandler := NewRubyGemsHandler(cfg, database, indexer, f, gdb)
api := NewAPI(cfg, database, apiV1Handler, rubygemsHandler)
Expand Down
5 changes: 2 additions & 3 deletions internal/cve/gemadvisorydb.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"gopkg.in/yaml.v3"

"github.com/gemfast/server/internal/config"
"github.com/gemfast/server/internal/license"
git "github.com/go-git/go-git/v5"

"github.com/akyoto/cache"
Expand Down Expand Up @@ -41,8 +40,8 @@ type GemAdvisoryDB struct {
cfg *config.Config
}

func NewGemAdvisoryDB(cfg *config.Config, l *license.License) *GemAdvisoryDB {
if !cfg.CVE.Enabled || !l.Validated {
func NewGemAdvisoryDB(cfg *config.Config) *GemAdvisoryDB {
if !cfg.CVE.Enabled {
log.Trace().Msg("ruby advisory db disabled")
}
advisoryDB := cache.New(24 * time.Hour)
Expand Down
51 changes: 3 additions & 48 deletions internal/db/db.go
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
package db

import (
"encoding/json"
"fmt"
"net/http"
"os"
"path/filepath"
"strconv"

"github.com/gemfast/server/internal/config"
"github.com/gemfast/server/internal/license"
"github.com/rs/zerolog/log"
"go.etcd.io/bbolt"
bolt "go.etcd.io/bbolt"
)

const (
GemBucket = "gems"
KeyBucket = "keys"
LicenseBucket = "license"
UserBucket = "users"
GemBucket = "gems"
KeyBucket = "keys"
UserBucket = "users"
)

type DB struct {
Expand Down Expand Up @@ -51,7 +48,6 @@ func (db *DB) Open() {
db.boltDB = boltDB
db.createBucket(GemBucket)
db.createBucket(KeyBucket)
db.createBucket(LicenseBucket)
db.createBucket(UserBucket)
}

Expand All @@ -78,7 +74,6 @@ func (db *DB) BucketStats() map[string]bbolt.BucketStats {
db.boltDB.View(func(tx *bolt.Tx) error {
bucketStatsMap[GemBucket] = tx.Bucket([]byte(GemBucket)).Stats()
bucketStatsMap[KeyBucket] = tx.Bucket([]byte(KeyBucket)).Stats()
bucketStatsMap[LicenseBucket] = tx.Bucket([]byte(LicenseBucket)).Stats()
bucketStatsMap[UserBucket] = tx.Bucket([]byte(UserBucket)).Stats()
return nil
})
Expand Down Expand Up @@ -112,43 +107,3 @@ func (db *DB) createBucket(bucket string) *bolt.Bucket {
}
return b
}

func (db *DB) GetLicense() (*license.License, error) {
l := &license.License{}
err := db.boltDB.View(func(tx *bolt.Tx) error {
b := tx.Bucket([]byte(LicenseBucket))
v := b.Get([]byte("license"))
err := json.Unmarshal(v, l)
if err != nil {
log.Error().Err(err).Msg("could not unmarshal license")
return err
}
return nil
})
if err != nil {
log.Error().Err(err).Msg("could not get license")
return nil, err
}
return l, nil
}

func (db *DB) SaveLicense(l *license.License) error {
err := db.boltDB.Update(func(tx *bolt.Tx) error {
b := tx.Bucket([]byte(LicenseBucket))
licenseBytes, err := json.Marshal(l)
if err != nil {
return fmt.Errorf("could not marshal gem to json: %v", err)
}
err = b.Put([]byte("license"), []byte(licenseBytes))
if err != nil {
log.Error().Err(err).Msg("could not persist license")
return err
}
return nil
})
if err != nil {
log.Error().Err(err).Msg("could not persist license")
return err
}
return nil
}
5 changes: 2 additions & 3 deletions internal/filter/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"regexp"

"github.com/gemfast/server/internal/config"
"github.com/gemfast/server/internal/license"
"github.com/rs/zerolog/log"
)

Expand All @@ -14,9 +13,9 @@ type RegexFilter struct {
enabled bool
}

func NewFilter(cfg *config.Config, l *license.License) *RegexFilter {
func NewFilter(cfg *config.Config) *RegexFilter {
enabled := false
if cfg.Filter.Enabled && l.Validated {
if cfg.Filter.Enabled {
log.Trace().Msg("gem filter enabled")
enabled = true
}
Expand Down
5 changes: 2 additions & 3 deletions internal/filter/filter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"testing"

"github.com/gemfast/server/internal/config"
"github.com/gemfast/server/internal/license"
)

func TestIsAllowed(t *testing.T) {
Expand All @@ -14,7 +13,7 @@ func TestIsAllowed(t *testing.T) {
Regex: []string{"webmock*"},
Action: "deny",
}
f := NewFilter(cfg, &license.License{Validated: true})
f := NewFilter(cfg)
allowed := f.IsAllowed("webmock-3.18.1.gem")
if allowed {
t.Errorf("DenyList: expected webmock-3.18.1.gem to be denied")
Expand All @@ -25,7 +24,7 @@ func TestIsAllowed(t *testing.T) {
}

cfg.Filter.Action = "allow"
f = NewFilter(cfg, &license.License{Validated: true})
f = NewFilter(cfg)
allowed = f.IsAllowed("webmock-3.18.1.gem")
if !allowed {
t.Errorf("AllowList: expected webmock-3.18.1.gem to be allowed")
Expand Down
Loading

0 comments on commit b447741

Please sign in to comment.