sops icon indicating copy to clipboard operation
sops copied to clipboard

A slimmed version of sops with age encryption as a Go module?

Open MarcCoquand opened this issue 7 months ago • 6 comments

Hi!

Thank you so much for developing this tool.

Right now I'm using the Go Sops module in my project to decrypt my secrets. It works, but I'm noticing that it's pulling in 20MB+ worth of dependencies, it is by far the largest dependency in the project.

I think this is because sops pulls in all cloud vendor SDKs.

My question, or request, is: Would it be possible to have a slimmed down version for use with Go, for example a sops-age module, that contains only the subset needed to encrypt/decrypt sops using age, and has fewer dependencies?

MarcCoquand avatar Apr 24 '26 09:04 MarcCoquand

That would be nice, I recently tried to use it as a tool for a legacy project. I pack every transitive dependency via gnu guix. And sops, single utility, makes this final nar archive unfathomably huge.

sunfora avatar May 18 '26 22:05 sunfora

multiple sops binaries should be available to match the usage they are made for. I also have issues with the size, when working with micro-services the sops size makes the docker image double initial size or more.

I am not a go dev so I do not know the effort needed but I suggest:

  • a sops-exec-<techno>, for age : sops-exec-age, that would only contain the part of sops exec command for the given techno
  • keep the sops as is for all the other commands

for age, I trimmed the size down from 50Mo to 15Mo with only basic go knowledge, the gain is already huge and it can be optimized

itineric avatar May 20 '26 09:05 itineric

This seems to be a coupling issue regarding the core of the tool itself.

if you take a look at somewhere like config/config.go, you'll see imports like this:

import (
	"fmt"
	"os"
	"path"
	"path/filepath"
	"regexp"
	"strings"

	"github.com/getsops/sops/v3"
	"github.com/getsops/sops/v3/age"
	"github.com/getsops/sops/v3/azkv"
	"github.com/getsops/sops/v3/gcpkms"
	"github.com/getsops/sops/v3/hckms"
	"github.com/getsops/sops/v3/hcvault"
	"github.com/getsops/sops/v3/kms"
	"github.com/getsops/sops/v3/pgp"
	"github.com/getsops/sops/v3/plugin"
	"github.com/getsops/sops/v3/publish"
	"go.yaml.in/yaml/v3"
)

all master keys and their respective heavy cloud SDKs are explicitly imported to make the config parser work-

this usually isn't an issue for standalone CLIs, but since SOPS is widely used as a Go module, it makes the dependency tree quite big for everyone

I was playing around with Dependency Inversion to decouple this, but it quickly became a 3k+ line diff, which feels way too intrusive for the maintainers to review right now.

maybe #2016 can help? But honestly, it feels like a band-aid solution, because this is an architecture issue rather than an integration issue

Dexmachi avatar Jun 29 '26 13:06 Dexmachi

As well as binary size this is also a CVE churn issue for us. A Vault only or age only user still compiles the full AWS, Azure, GCP and Huawei SDKs and their transitive graph, so they inherit every future CVE and dependency bump from code they never call.

Would maintainers be open to build tag gated optional backends in the main tree? Each backend would be gated behind a build tag, with the default build unchanged (all backends on). A consumer who only needs one does something like go build -tags 'sops_minimal sops_age' ./cmd/sops

I understand from #2016 that this probably ins't the desired solution but as far as I can tell build tags have never been proposed here, so I just want to gauge if people would find this useful.

JvD-Ericsson avatar Sep 18 '26 14:09 JvD-Ericsson

As well as binary size this is also a CVE churn issue for us. A Vault only or age only user still compiles the full AWS, Azure, GCP and Huawei SDKs and their transitive graph, so they inherit every future CVE and dependency bump from code they never call.

While I also want a smaller binary/library, the "CVE from uncalled code" argument is very weak. You should use a better vulnerability scanner: https://words.filippo.io/dependabot/

msfjarvis avatar Sep 19 '26 04:09 msfjarvis

As well as binary size this is also a CVE churn issue for us. A Vault only or age only user still compiles the full AWS, Azure, GCP and Huawei SDKs and their transitive graph, so they inherit every future CVE and dependency bump from code they never call.

While I also want a smaller binary/library, the "CVE from uncalled code" argument is very weak. You should use a better vulnerability scanner: https://words.filippo.io/dependabot/

I think we're talking past each other on "CVE from uncalled code." I mean if we only use Vault, and there is a real CVE in a backend I don't use (say an unused KMS provider) that is statically reachable from main (so govulncheck correctly reports it as affected), but in my usecase I only ever use Vault, so that path is never actually executed. govulncheck would still report that CVE. The only way to stop carrying that surface is to not compile it in, which is exactly the build-tag question.

Either way that wasn't really my question. What I'm after is people's opinions on backends gated behind a build tag versus the #2016 plugin work?

JvD-Ericsson avatar Sep 21 '26 15:09 JvD-Ericsson