Require access to Still via method
This commit adds a safeguard to accessing the still from a specific component by requiring access via the component.GetStill method.
This commit is contained in:
parent
81fa84c244
commit
8235ea9105
63 changed files with 288 additions and 197 deletions
|
|
@ -35,8 +35,10 @@ var (
|
|||
// NoPrefix checks if this WissKI instance is excluded from generating prefixes.
|
||||
// TODO: Move this to the database!
|
||||
func (prefixes *Prefixes) NoPrefix() bool {
|
||||
liquid := ingredient.GetLiquid(prefixes)
|
||||
|
||||
// FIXME: Ignoring error here!
|
||||
exists, _ := fsx.IsRegular(filepath.Join(prefixes.FilesystemBase, "prefixes.skip"), false)
|
||||
exists, _ := fsx.IsRegular(filepath.Join(liquid.FilesystemBase, "prefixes.skip"), false)
|
||||
return exists
|
||||
}
|
||||
|
||||
|
|
@ -63,9 +65,8 @@ func (prefixes *Prefixes) All(ctx context.Context, server *phpx.Server) ([]strin
|
|||
|
||||
// getLivePrefixes get the list of prefixes found within the live system
|
||||
func (prefixes *Prefixes) getLivePrefixes(ctx context.Context, server *phpx.Server) (pfs []string, err error) {
|
||||
useTS := !(prefixes.Config.TS.DangerouslyUseAdapterPrefixes.Set && prefixes.Config.TS.DangerouslyUseAdapterPrefixes.Value)
|
||||
|
||||
if useTS {
|
||||
danger := ingredient.GetStill(prefixes).Config.TS.DangerouslyUseAdapterPrefixes
|
||||
if !(danger.Set && danger.Value) {
|
||||
pfs, err = prefixes.getTSPrefixes(ctx, server)
|
||||
} else {
|
||||
// danger danger danger: Use the adapter prefixes
|
||||
|
|
@ -107,9 +108,11 @@ func (wisski *Prefixes) getTSPrefixes(ctx context.Context, server *phpx.Server)
|
|||
}
|
||||
|
||||
func (prefixes *Prefixes) blocked() ([]string, error) {
|
||||
config := ingredient.GetStill(prefixes).Config
|
||||
|
||||
// open the resolver block file
|
||||
// TODO: move this to the distillery
|
||||
file, err := os.Open(prefixes.Malt.Config.Paths.ResolverBlocks)
|
||||
file, err := os.Open(config.Paths.ResolverBlocks)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
@ -145,7 +148,7 @@ func hasAnyPrefix(candidate string, prefixes []string) bool {
|
|||
}
|
||||
|
||||
func (wisski *Prefixes) filePrefixes() (prefixes []string, err error) {
|
||||
path := filepath.Join(wisski.FilesystemBase, "prefixes")
|
||||
path := filepath.Join(ingredient.GetLiquid(wisski).FilesystemBase, "prefixes")
|
||||
|
||||
// check that the prefixes path exists
|
||||
{
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ var requirementsPHP string
|
|||
|
||||
// Create creates a new block with the given title and html content
|
||||
func (requirements *Requirements) Get(ctx context.Context, server *phpx.Server) (data []status.Requirement, err error) {
|
||||
err = requirements.dependencies.PHP.ExecScript(ctx, server, &data, requirementsPHP, "get_requirements", requirements.URL().String())
|
||||
err = requirements.dependencies.PHP.ExecScript(ctx, server, &data, requirementsPHP, "get_requirements", ingredient.GetLiquid(requirements).URL().String())
|
||||
if err == nil {
|
||||
// sort first by weight, then by id!
|
||||
slices.SortFunc(data, func(a, b status.Requirement) int {
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ func (up *UserPolicy) Fetch(flags ingredient.FetcherFlags, target *status.WissKI
|
|||
}
|
||||
|
||||
// read the grants into the info struct
|
||||
target.Grants, err = up.Malt.Policy.Instance(flags.Context, up.Slug)
|
||||
liquid := ingredient.GetLiquid(up)
|
||||
target.Grants, err = liquid.Policy.Instance(flags.Context, liquid.Slug)
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ func (u *Users) LoginWithOpt(ctx context.Context, server *phpx.Server, username
|
|||
}
|
||||
|
||||
// and resolve the (possibly relative) reference
|
||||
dest = u.URL().ResolveReference(dest)
|
||||
dest = ingredient.GetLiquid(u).URL().ResolveReference(dest)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue