|
| 1 | +// Copyright 2024 Woodpecker Authors |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | + |
| 15 | +package compiler |
| 16 | + |
| 17 | +import backend_types "go.woodpecker-ci.org/woodpecker/v2/pipeline/backend/types" |
| 18 | + |
| 19 | +/* cSpell:disable */ |
| 20 | + |
| 21 | +var binaryVars = []string{ |
| 22 | + "PATH", // Specifies directories to search for executable files |
| 23 | + "PATH_SEPARATOR", // Defines the separator used in the PATH variable |
| 24 | + "COMMAND_MODE", // (macOS): Can affect how certain commands are interpreted |
| 25 | + "DYLD_FALLBACK_FRAMEWORK_PATH", // (macOS): Specifies additional locations to search for frameworks |
| 26 | + "DYLD_FALLBACK_LIBRARY_PATH", // (macOS): Specifies additional locations to search for libraries |
| 27 | +} |
| 28 | + |
| 29 | +var libraryVars = []string{ |
| 30 | + "LD_PRELOAD", // Specifies shared libraries to be loaded before all others |
| 31 | + "LD_LIBRARY_PATH", // Specifies directories to search for shared libraries before the standard locations |
| 32 | + "LD_AUDIT", // Specifies a shared object to be used for auditing |
| 33 | + "LD_BIND_NOW", // Forces all relocations to be processed immediately |
| 34 | + "LD_PROFILE", // Specifies a shared object to be used for profiling |
| 35 | + "LIBPATH", // (AIX): Similar to LD_LIBRARY_PATH on AIX systems |
| 36 | + "DYLD_INSERT_LIBRARIES", // (macOS): Similar to LD_PRELOAD on macOS |
| 37 | + "DYLD_LIBRARY_PATH", // (macOS): Similar to LD_LIBRARY_PATH on macOS |
| 38 | +} |
| 39 | + |
| 40 | +/* cSpell:enable */ |
| 41 | + |
| 42 | +func environmentAllowed(envKey string, stepType backend_types.StepType) bool { |
| 43 | + switch stepType { |
| 44 | + case backend_types.StepTypePlugin, |
| 45 | + backend_types.StepTypeClone: |
| 46 | + for _, v := range append(binaryVars, libraryVars...) { |
| 47 | + if envKey == v { |
| 48 | + return false |
| 49 | + } |
| 50 | + } |
| 51 | + } |
| 52 | + return true |
| 53 | +} |
0 commit comments