Debian Codegraph @

pathrs-lite/internal/errors_linux.go

raw
1 // SPDX-License-Identifier: MPL-2.0
2
3 //go:build linux
4
5 // Copyright (C) 2024-2025 Aleksa Sarai <[email protected]>
6 // Copyright (C) 2024-2025 SUSE LLC
7 //
8 // This Source Code Form is subject to the terms of the Mozilla Public
9 // License, v. 2.0. If a copy of the MPL was not distributed with this
10 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
11
12 // Package internal contains unexported common code for filepath-securejoin.
13 package internal
14
15 import (
16 "errors"
17
18 "golang.org/x/sys/unix"
19 )
20
21 type xdevErrorish struct {
22 description string
23 }
24
25 func (err xdevErrorish) Error() string { return err.description }
26 func (err xdevErrorish) Is(target error) bool { return target == unix.EXDEV }
27
28 var (
29 // ErrPossibleAttack indicates that some attack was detected.
30 ErrPossibleAttack error = xdevErrorish{"possible attack detected"}
31
32 // ErrPossibleBreakout indicates that during an operation we ended up in a
33 // state that could be a breakout but we detected it.
34 ErrPossibleBreakout error = xdevErrorish{"possible breakout detected"}
35
36 // ErrInvalidDirectory indicates an unlinked directory.
37 ErrInvalidDirectory = errors.New("wandered into deleted directory")
38
39 // ErrDeletedInode indicates an unlinked file (non-directory).
40 ErrDeletedInode = errors.New("cannot verify path of deleted inode")
41 )