Feat v0.8.0 files module (#67)
All checks were successful
CI/CD / detect-changes (push) Successful in 4s
CI/CD / test-frontend (push) Has been skipped
CI/CD / test-runners (push) Has been skipped
CI/CD / e2e-smoke (push) Has been skipped
CI/CD / test-go-pg (push) Successful in 2m45s
CI/CD / test-sqlite (push) Successful in 2m52s
CI/CD / build-and-deploy (push) Successful in 1m20s
All checks were successful
CI/CD / detect-changes (push) Successful in 4s
CI/CD / test-frontend (push) Has been skipped
CI/CD / test-runners (push) Has been skipped
CI/CD / e2e-smoke (push) Has been skipped
CI/CD / test-go-pg (push) Successful in 2m45s
CI/CD / test-sqlite (push) Successful in 2m52s
CI/CD / build-and-deploy (push) Successful in 1m20s
Co-authored-by: Jeffrey Smith <jasafpro@gmail.com> Co-committed-by: Jeffrey Smith <jasafpro@gmail.com>
This commit was merged in pull request #67.
This commit is contained in:
@@ -33,6 +33,7 @@ import (
|
||||
"armature/events"
|
||||
"armature/metrics"
|
||||
"armature/models"
|
||||
"armature/storage"
|
||||
"armature/store"
|
||||
)
|
||||
|
||||
@@ -77,6 +78,7 @@ type Runner struct {
|
||||
dbPostgres bool // true = use $N placeholders; false = use ?
|
||||
allowPrivateIPs bool
|
||||
bus *events.Bus
|
||||
objectStore storage.ObjectStore // nil = files module unavailable
|
||||
}
|
||||
|
||||
// NewRunner creates a runner with the given sandbox and dependencies.
|
||||
@@ -116,6 +118,11 @@ func (r *Runner) SetBus(bus *events.Bus) {
|
||||
r.bus = bus
|
||||
}
|
||||
|
||||
// SetObjectStore attaches the blob storage backend for the files module.
|
||||
func (r *Runner) SetObjectStore(s storage.ObjectStore) {
|
||||
r.objectStore = s
|
||||
}
|
||||
|
||||
// SetAllowPrivateIPs disables the SSRF check that blocks connections to
|
||||
// private/loopback IPs. For self-hosted environments where extensions
|
||||
// reach internal services. Controlled by EXT_ALLOW_PRIVATE_IPS env var.
|
||||
@@ -336,8 +343,9 @@ func (r *Runner) buildModulesWithLibCtx(ctx context.Context, packageID string, m
|
||||
|
||||
modules := make(map[string]starlark.Value)
|
||||
|
||||
// Track db permission level: 0=none, 1=read, 2=write
|
||||
// Track tiered permission levels: 0=none, 1=read, 2=write
|
||||
dbLevel := 0
|
||||
filesLevel := 0
|
||||
hasBatchExec := false
|
||||
|
||||
for _, perm := range granted {
|
||||
@@ -363,6 +371,14 @@ func (r *Runner) buildModulesWithLibCtx(ctx context.Context, packageID string, m
|
||||
case models.ExtPermDBWrite:
|
||||
dbLevel = 2
|
||||
|
||||
case models.ExtPermFilesRead:
|
||||
if filesLevel < 1 {
|
||||
filesLevel = 1
|
||||
}
|
||||
|
||||
case models.ExtPermFilesWrite:
|
||||
filesLevel = 2
|
||||
|
||||
case models.ExtPermWorkflowAccess:
|
||||
modules["workflow"] = BuildWorkflowModule(ctx, r.stores)
|
||||
|
||||
@@ -391,6 +407,15 @@ func (r *Runner) buildModulesWithLibCtx(ctx context.Context, packageID string, m
|
||||
})
|
||||
}
|
||||
|
||||
// Wire files module at the highest granted level.
|
||||
if filesLevel > 0 && r.objectStore != nil {
|
||||
modules["files"] = BuildFilesModule(ctx, FilesModuleConfig{
|
||||
PackageID: packageID,
|
||||
CanWrite: filesLevel == 2,
|
||||
Store: r.objectStore,
|
||||
})
|
||||
}
|
||||
|
||||
// A package reads its own admin + team + user settings.
|
||||
userID := ""
|
||||
teamID := ""
|
||||
|
||||
Reference in New Issue
Block a user