_id stringlengths 2 7 | title stringlengths 1 118 | partition stringclasses 3
values | text stringlengths 52 85.5k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q171500 | Claims | validation | func (v *JWTValidator) Claims(r *http.Request, token *jwt.JSONWebToken, values ...interface{}) error {
key, err := v.config.secretProvider.GetSecret(r)
if err != nil {
return err
}
return token.Claims(key, values...)
} | go | {
"resource": ""
} |
q171501 | NewJWKClient | validation | func NewJWKClient(options JWKClientOptions, extractor RequestTokenExtractor) *JWKClient {
return NewJWKClientWithCache(options, extractor, nil)
} | go | {
"resource": ""
} |
q171502 | NewJWKClientWithCache | validation | func NewJWKClientWithCache(options JWKClientOptions, extractor RequestTokenExtractor, keyCacher KeyCacher) *JWKClient {
if extractor == nil {
extractor = RequestTokenExtractorFunc(FromHeader)
}
if keyCacher == nil {
keyCacher = newMemoryPersistentKeyCacher()
}
if options.Client == nil {
options.Client = http... | go | {
"resource": ""
} |
q171503 | GetKey | validation | func (j *JWKClient) GetKey(ID string) (jose.JSONWebKey, error) {
j.mu.Lock()
defer j.mu.Unlock()
searchedKey, err := j.keyCacher.Get(ID)
if err != nil {
keys, err := j.downloadKeys()
if err != nil {
return jose.JSONWebKey{}, err
}
addedKey, err := j.keyCacher.Add(ID, keys)
if err != nil {
return jo... | go | {
"resource": ""
} |
q171504 | GetSecret | validation | func (j *JWKClient) GetSecret(r *http.Request) (interface{}, error) {
token, err := j.extractor.Extract(r)
if err != nil {
return nil, err
}
if len(token.Headers) < 1 {
return nil, ErrNoJWTHeaders
}
header := token.Headers[0]
return j.GetKey(header.KeyID)
} | go | {
"resource": ""
} |
q171505 | FromMultiple | validation | func FromMultiple(extractors ...RequestTokenExtractor) RequestTokenExtractor {
return RequestTokenExtractorFunc(func(r *http.Request) (*jwt.JSONWebToken, error) {
for _, e := range extractors {
token, err := e.Extract(r)
if err == ErrTokenNotFound {
continue
} else if err != nil {
return nil, err
... | go | {
"resource": ""
} |
q171506 | FromParams | validation | func FromParams(r *http.Request) (*jwt.JSONWebToken, error) {
if r == nil {
return nil, ErrNilRequest
}
raw := r.URL.Query().Get("token")
if raw == "" {
return nil, ErrTokenNotFound
}
return jwt.ParseSigned(raw)
} | go | {
"resource": ""
} |
q171507 | NewMemoryKeyCacher | validation | func NewMemoryKeyCacher(maxKeyAge time.Duration, maxCacheSize int) KeyCacher {
return &memoryKeyCacher{
entries: map[string]keyCacherEntry{},
maxKeyAge: maxKeyAge,
maxCacheSize: maxCacheSize,
}
} | go | {
"resource": ""
} |
q171508 | Get | validation | func (mkc *memoryKeyCacher) Get(keyID string) (*jose.JSONWebKey, error) {
searchKey, ok := mkc.entries[keyID]
if ok {
if mkc.maxKeyAge == MaxKeyAgeNoCheck || !mkc.keyIsExpired(keyID) {
return &searchKey.JSONWebKey, nil
}
return nil, ErrKeyExpired
}
return nil, ErrNoKeyFound
} | go | {
"resource": ""
} |
q171509 | Add | validation | func (mkc *memoryKeyCacher) Add(keyID string, downloadedKeys []jose.JSONWebKey) (*jose.JSONWebKey, error) {
var addingKey jose.JSONWebKey
for _, key := range downloadedKeys {
if key.KeyID == keyID {
addingKey = key
}
if mkc.maxCacheSize == -1 {
mkc.entries[key.KeyID] = keyCacherEntry{
addedAt: tim... | go | {
"resource": ""
} |
q171510 | keyIsExpired | validation | func (mkc *memoryKeyCacher) keyIsExpired(keyID string) bool {
if time.Now().After(mkc.entries[keyID].addedAt.Add(mkc.maxKeyAge)) {
delete(mkc.entries, keyID)
return true
}
return false
} | go | {
"resource": ""
} |
q171511 | handleOverflow | validation | func (mkc *memoryKeyCacher) handleOverflow() {
if mkc.maxCacheSize < len(mkc.entries) {
var oldestEntryKeyID string
var latestAddedTime = time.Now()
for entryKeyID, entry := range mkc.entries {
if entry.addedAt.Before(latestAddedTime) {
latestAddedTime = entry.addedAt
oldestEntryKeyID = entryKeyID
... | go | {
"resource": ""
} |
q171512 | Patch | validation | func Patch(old io.Reader, new io.Writer, patch io.Reader) error {
var hdr header
err := binary.Read(patch, signMagLittleEndian{}, &hdr)
if err != nil {
return err
}
if hdr.Magic != magic {
return ErrCorrupt
}
if hdr.CtrlLen < 0 || hdr.DiffLen < 0 || hdr.NewSize < 0 {
return ErrCorrupt
}
ctrlbuf := make(... | go | {
"resource": ""
} |
q171513 | Diff | validation | func Diff(old, new io.Reader, patch io.Writer) error {
obuf, err := ioutil.ReadAll(old)
if err != nil {
return err
}
nbuf, err := ioutil.ReadAll(new)
if err != nil {
return err
}
pbuf, err := diffBytes(obuf, nbuf)
if err != nil {
return err
}
_, err = patch.Write(pbuf)
return err
} | go | {
"resource": ""
} |
q171514 | validColor | validation | func validColor(c string) bool {
valid := false
if validColors[c] {
valid = true
}
return valid
} | go | {
"resource": ""
} |
q171515 | New | validation | func New(cs []string, d time.Duration, options ...Option) *Spinner {
s := &Spinner{
Delay: d,
chars: cs,
color: color.New(color.FgWhite).SprintFunc(),
lock: &sync.RWMutex{},
Writer: color.Output,
active: false,
stopChan: make(chan struct{}, 1),
}
for _, option := range options {
opt... | go | {
"resource": ""
} |
q171516 | Start | validation | func (s *Spinner) Start() {
s.lock.Lock()
if s.active {
s.lock.Unlock()
return
}
if s.HideCursor && runtime.GOOS != "windows" {
// hides the cursor
fmt.Print("\033[?25l")
}
s.active = true
s.lock.Unlock()
go func() {
for {
for i := 0; i < len(s.chars); i++ {
select {
case <-s.stopChan:
... | go | {
"resource": ""
} |
q171517 | Stop | validation | func (s *Spinner) Stop() {
s.lock.Lock()
defer s.lock.Unlock()
if s.active {
s.active = false
if s.HideCursor && runtime.GOOS != "windows" {
// makes the cursor visible
fmt.Print("\033[?25h")
}
s.erase()
if s.FinalMSG != "" {
fmt.Fprintf(s.Writer, s.FinalMSG)
}
s.stopChan <- struct{}{}
}
} | go | {
"resource": ""
} |
q171518 | Reverse | validation | func (s *Spinner) Reverse() {
s.lock.Lock()
defer s.lock.Unlock()
for i, j := 0, len(s.chars)-1; i < j; i, j = i+1, j-1 {
s.chars[i], s.chars[j] = s.chars[j], s.chars[i]
}
} | go | {
"resource": ""
} |
q171519 | Color | validation | func (s *Spinner) Color(colors ...string) error {
colorAttributes := make([]color.Attribute, len(colors))
// Verify colours are valid and place the appropriate attribute in the array
for index, c := range colors {
if !validColor(c) {
return errInvalidColor
}
colorAttributes[index] = colorAttributeMap[c]
... | go | {
"resource": ""
} |
q171520 | UpdateSpeed | validation | func (s *Spinner) UpdateSpeed(d time.Duration) {
s.lock.Lock()
defer s.lock.Unlock()
s.Delay = d
} | go | {
"resource": ""
} |
q171521 | UpdateCharSet | validation | func (s *Spinner) UpdateCharSet(cs []string) {
s.lock.Lock()
defer s.lock.Unlock()
s.chars = cs
} | go | {
"resource": ""
} |
q171522 | erase | validation | func (s *Spinner) erase() {
n := utf8.RuneCountInString(s.lastOutput)
if runtime.GOOS == "windows" {
clearString := "\r"
for i := 0; i < n; i++ {
clearString += " "
}
fmt.Fprintf(s.Writer, clearString)
return
}
del, _ := hex.DecodeString("7f")
for _, c := range []string{
"\b",
string(del),
"\b",... | go | {
"resource": ""
} |
q171523 | GenerateNumberSequence | validation | func GenerateNumberSequence(length int) []string {
numSeq := make([]string, length)
for i := 0; i < length; i++ {
numSeq[i] = strconv.Itoa(i)
}
return numSeq
} | go | {
"resource": ""
} |
q171524 | header | validation | func (id *streamID) header(tag uint64) uint64 {
header := id.id<<3 | tag
if !id.initiator {
header--
}
return header
} | go | {
"resource": ""
} |
q171525 | NewMultiplex | validation | func NewMultiplex(con net.Conn, initiator bool) *Multiplex {
mp := &Multiplex{
con: con,
initiator: initiator,
buf: bufio.NewReader(con),
channels: make(map[streamID]*Stream),
closed: make(chan struct{}),
shutdown: make(chan struct{}),
wrTkn: make(chan struct{}, 1),
nstreams: make... | go | {
"resource": ""
} |
q171526 | Accept | validation | func (m *Multiplex) Accept() (*Stream, error) {
select {
case s, ok := <-m.nstreams:
if !ok {
return nil, errors.New("multiplex closed")
}
return s, nil
case <-m.closed:
return nil, m.shutdownErr
}
} | go | {
"resource": ""
} |
q171527 | NewNamedStream | validation | func (mp *Multiplex) NewNamedStream(name string) (*Stream, error) {
mp.chLock.Lock()
// We could call IsClosed but this is faster (given that we already have
// the lock).
if mp.channels == nil {
mp.chLock.Unlock()
return nil, ErrShutdown
}
sid := mp.nextChanID()
header := (sid << 3) | newStreamTag
if na... | go | {
"resource": ""
} |
q171528 | encodeInt | validation | func encodeInt(lat, lng float64) uint64 {
latInt := encodeRange(lat, 90)
lngInt := encodeRange(lng, 180)
return interleave(latInt, lngInt)
} | go | {
"resource": ""
} |
q171529 | Center | validation | func (b Box) Center() (lat, lng float64) {
lat = (b.MinLat + b.MaxLat) / 2.0
lng = (b.MinLng + b.MaxLng) / 2.0
return
} | go | {
"resource": ""
} |
q171530 | Round | validation | func (b Box) Round() (lat, lng float64) {
x := maxDecimalPower(b.MaxLat - b.MinLat)
lat = math.Ceil(b.MinLat/x) * x
x = maxDecimalPower(b.MaxLng - b.MinLng)
lng = math.Ceil(b.MinLng/x) * x
return
} | go | {
"resource": ""
} |
q171531 | BoundingBox | validation | func BoundingBox(hash string) Box {
bits := uint(5 * len(hash))
inthash := base32encoding.Decode(hash)
return BoundingBoxIntWithPrecision(inthash, bits)
} | go | {
"resource": ""
} |
q171532 | BoundingBoxIntWithPrecision | validation | func BoundingBoxIntWithPrecision(hash uint64, bits uint) Box {
fullHash := hash << (64 - bits)
latInt, lngInt := deinterleave(fullHash)
lat := decodeRange(latInt, 90)
lng := decodeRange(lngInt, 180)
latErr, lngErr := errorWithPrecision(bits)
return Box{
MinLat: lat,
MaxLat: lat + latErr,
MinLng: lng,
MaxL... | go | {
"resource": ""
} |
q171533 | DecodeCenter | validation | func DecodeCenter(hash string) (lat, lng float64) {
box := BoundingBox(hash)
return box.Center()
} | go | {
"resource": ""
} |
q171534 | Neighbors | validation | func Neighbors(hash string) []string {
box := BoundingBox(hash)
lat, lng := box.Center()
latDelta := box.MaxLat - box.MinLat
lngDelta := box.MaxLng - box.MinLng
precision := uint(len(hash))
return []string{
// N
EncodeWithPrecision(lat+latDelta, lng, precision),
// NE,
EncodeWithPrecision(lat+latDelta, ln... | go | {
"resource": ""
} |
q171535 | NeighborsIntWithPrecision | validation | func NeighborsIntWithPrecision(hash uint64, bits uint) []uint64 {
box := BoundingBoxIntWithPrecision(hash, bits)
lat, lng := box.Center()
latDelta := box.MaxLat - box.MinLat
lngDelta := box.MaxLng - box.MinLng
return []uint64{
// N
EncodeIntWithPrecision(lat+latDelta, lng, bits),
// NE,
EncodeIntWithPrecis... | go | {
"resource": ""
} |
q171536 | NeighborIntWithPrecision | validation | func NeighborIntWithPrecision(hash uint64, bits uint, direction Direction) uint64 {
return NeighborsIntWithPrecision(hash, bits)[direction]
} | go | {
"resource": ""
} |
q171537 | spread | validation | func spread(x uint32) uint64 {
X := uint64(x)
X = (X | (X << 16)) & 0x0000ffff0000ffff
X = (X | (X << 8)) & 0x00ff00ff00ff00ff
X = (X | (X << 4)) & 0x0f0f0f0f0f0f0f0f
X = (X | (X << 2)) & 0x3333333333333333
X = (X | (X << 1)) & 0x5555555555555555
return X
} | go | {
"resource": ""
} |
q171538 | newEncoding | validation | func newEncoding(encoder string) *encoding {
e := new(encoding)
e.encode = encoder
for i := 0; i < len(e.decode); i++ {
e.decode[i] = 0xff
}
for i := 0; i < len(encoder); i++ {
e.decode[encoder[i]] = byte(i)
}
return e
} | go | {
"resource": ""
} |
q171539 | Encode | validation | func (e *encoding) Encode(x uint64) string {
b := [12]byte{}
for i := 0; i < 12; i++ {
b[11-i] = e.encode[x&0x1f]
x >>= 5
}
return string(b[:])
} | go | {
"resource": ""
} |
q171540 | InitArgs | validation | func InitArgs(args ...string) func(*LinuxFactory) error {
return func(l *LinuxFactory) error {
name := args[0]
if filepath.Base(name) == name {
if lp, err := exec.LookPath(name); err == nil {
name = lp
}
}
l.InitPath = name
l.InitArgs = append([]string{name}, args[1:]...)
return nil
}
} | go | {
"resource": ""
} |
q171541 | InitPath | validation | func InitPath(path string, args ...string) func(*LinuxFactory) error {
return func(l *LinuxFactory) error {
l.InitPath = path
l.InitArgs = args
return nil
}
} | go | {
"resource": ""
} |
q171542 | StartInitialization | validation | func (l *LinuxFactory) StartInitialization() (err error) {
pipefd, err := strconv.Atoi(os.Getenv("_LIBCONTAINER_INITPIPE"))
if err != nil {
return err
}
var (
pipe = os.NewFile(uintptr(pipefd), "pipe")
it = initType(os.Getenv("_LIBCONTAINER_INITTYPE"))
)
// clear the current process's environment to clean... | go | {
"resource": ""
} |
q171543 | newConsole | validation | func newConsole(uid, gid int) (Console, error) {
master, err := os.OpenFile("/dev/ptmx", syscall.O_RDWR|syscall.O_NOCTTY|syscall.O_CLOEXEC, 0)
if err != nil {
return nil, err
}
console, err := ptsname(master)
if err != nil {
return nil, err
}
if err := unlockpt(master); err != nil {
return nil, err
}
if ... | go | {
"resource": ""
} |
q171544 | mount | validation | func (c *linuxConsole) mount(rootfs, mountLabel string, uid, gid int) error {
oldMask := syscall.Umask(0000)
defer syscall.Umask(oldMask)
if err := label.SetFileLabel(c.slavePath, mountLabel); err != nil {
return err
}
dest := filepath.Join(rootfs, "/dev/console")
f, err := os.Create(dest)
if err != nil && !os... | go | {
"resource": ""
} |
q171545 | dupStdio | validation | func (c *linuxConsole) dupStdio() error {
slave, err := c.open(syscall.O_RDWR)
if err != nil {
return err
}
fd := int(slave.Fd())
for _, i := range []int{0, 1, 2} {
if err := syscall.Dup3(fd, i, 0); err != nil {
return err
}
}
return nil
} | go | {
"resource": ""
} |
q171546 | open | validation | func (c *linuxConsole) open(flag int) (*os.File, error) {
r, e := syscall.Open(c.slavePath, flag, 0)
if e != nil {
return nil, &os.PathError{
Op: "open",
Path: c.slavePath,
Err: e,
}
}
return os.NewFile(uintptr(r), c.slavePath), nil
} | go | {
"resource": ""
} |
q171547 | ptsname | validation | func ptsname(f *os.File) (string, error) {
var n int32
if err := ioctl(f.Fd(), syscall.TIOCGPTN, uintptr(unsafe.Pointer(&n))); err != nil {
return "", err
}
return fmt.Sprintf("/dev/pts/%d", n), nil
} | go | {
"resource": ""
} |
q171548 | finalizeNamespace | validation | func finalizeNamespace(config *initConfig) error {
// Ensure that all unwanted fds we may have accidentally
// inherited are marked close-on-exec so they stay out of the
// container
if err := utils.CloseExecFrom(config.PassedFilesCount + 3); err != nil {
return err
}
capabilities := config.Config.Capabilities... | go | {
"resource": ""
} |
q171549 | joinExistingNamespaces | validation | func joinExistingNamespaces(namespaces []configs.Namespace) error {
for _, ns := range namespaces {
if ns.Path != "" {
f, err := os.OpenFile(ns.Path, os.O_RDONLY, 0)
if err != nil {
return err
}
err = system.Setns(f.Fd(), uintptr(ns.Syscall()))
f.Close()
if err != nil {
return err
}
}
... | go | {
"resource": ""
} |
q171550 | setupUser | validation | func setupUser(config *initConfig) error {
// Set up defaults.
defaultExecUser := user.ExecUser{
Uid: syscall.Getuid(),
Gid: syscall.Getgid(),
Home: "/",
}
passwdPath, err := user.GetPasswdPath()
if err != nil {
return err
}
groupPath, err := user.GetGroupPath()
if err != nil {
return err
}
execUs... | go | {
"resource": ""
} |
q171551 | killCgroupProcesses | validation | func killCgroupProcesses(m cgroups.Manager) error {
var procs []*os.Process
if err := m.Freeze(configs.Frozen); err != nil {
logrus.Warn(err)
}
pids, err := m.GetPids()
if err != nil {
m.Freeze(configs.Thawed)
return err
}
for _, pid := range pids {
if p, err := os.FindProcess(pid); err == nil {
procs... | go | {
"resource": ""
} |
q171552 | addUidGidMappings | validation | func (c *linuxContainer) addUidGidMappings(sys *syscall.SysProcAttr) error {
if c.config.UidMappings != nil {
sys.UidMappings = make([]syscall.SysProcIDMap, len(c.config.UidMappings))
for i, um := range c.config.UidMappings {
sys.UidMappings[i].ContainerID = um.ContainerID
sys.UidMappings[i].HostID = um.Host... | go | {
"resource": ""
} |
q171553 | dropBoundingSet | validation | func (w *whitelist) dropBoundingSet() error {
w.pid.Clear(capability.BOUNDS)
w.pid.Set(capability.BOUNDS, w.keep...)
return w.pid.Apply(capability.BOUNDS)
} | go | {
"resource": ""
} |
q171554 | drop | validation | func (w *whitelist) drop() error {
w.pid.Clear(allCapabilityTypes)
w.pid.Set(allCapabilityTypes, w.keep...)
return w.pid.Apply(allCapabilityTypes)
} | go | {
"resource": ""
} |
q171555 | ensureParent | validation | func (s *CpusetGroup) ensureParent(current, root string) error {
parent := filepath.Dir(current)
if filepath.Clean(parent) == root {
return nil
}
if err := s.ensureParent(parent, root); err != nil {
return err
}
if err := os.MkdirAll(current, 0755); err != nil && !os.IsExist(err) {
return err
}
return s.c... | go | {
"resource": ""
} |
q171556 | Pid | validation | func (p Process) Pid() (int, error) {
// math.MinInt32 is returned here, because it's invalid value
// for the kill() system call.
if p.ops == nil {
return math.MinInt32, newGenericError(fmt.Errorf("invalid process"), ProcessNotExecuted)
}
return p.ops.pid(), nil
} | go | {
"resource": ""
} |
q171557 | Signal | validation | func (p Process) Signal(sig os.Signal) error {
if p.ops == nil {
return newGenericError(fmt.Errorf("invalid process"), ProcessNotExecuted)
}
return p.ops.signal(sig)
} | go | {
"resource": ""
} |
q171558 | NewConsole | validation | func (p *Process) NewConsole(rootuid int) (Console, error) {
console, err := newConsole(rootuid, rootuid)
if err != nil {
return nil, err
}
p.consolePath = console.Path()
return console, nil
} | go | {
"resource": ""
} |
q171559 | setupRootfs | validation | func setupRootfs(config *configs.Config, console *linuxConsole) (err error) {
if err := prepareRoot(config); err != nil {
return newSystemError(err)
}
for _, m := range config.Mounts {
for _, precmd := range m.PremountCmds {
if err := mountCmd(precmd); err != nil {
return newSystemError(err)
}
}
if... | go | {
"resource": ""
} |
q171560 | createDevices | validation | func createDevices(config *configs.Config) error {
oldMask := syscall.Umask(0000)
for _, node := range config.Devices {
// containers running in a user namespace are not allowed to mknod
// devices so we can just bind mount it from the host.
if err := createDeviceNode(config.Rootfs, node, config.Namespaces.Cont... | go | {
"resource": ""
} |
q171561 | createDeviceNode | validation | func createDeviceNode(rootfs string, node *configs.Device, bind bool) error {
dest := filepath.Join(rootfs, node.Path)
if err := os.MkdirAll(filepath.Dir(dest), 0755); err != nil {
return err
}
if bind {
f, err := os.Create(dest)
if err != nil && !os.IsExist(err) {
return err
}
if f != nil {
f.Clos... | go | {
"resource": ""
} |
q171562 | remountReadonly | validation | func remountReadonly(path string) error {
for i := 0; i < 5; i++ {
if err := syscall.Mount("", path, "", syscall.MS_REMOUNT|syscall.MS_RDONLY, ""); err != nil && !os.IsNotExist(err) {
switch err {
case syscall.EINVAL:
// Probably not a mountpoint, use bind-mount
if err := syscall.Mount(path, path, "", ... | go | {
"resource": ""
} |
q171563 | joinCpuset | validation | func joinCpuset(c *configs.Cgroup, pid int) error {
path, err := getSubsystemPath(c, "cpuset")
if err != nil && !cgroups.IsNotFound(err) {
return err
}
s := &fs.CpusetGroup{}
return s.ApplyDir(path, c, pid)
} | go | {
"resource": ""
} |
q171564 | joinBlkio | validation | func joinBlkio(c *configs.Cgroup, pid int) error {
path, err := getSubsystemPath(c, "blkio")
if err != nil {
return err
}
if c.BlkioWeightDevice != "" {
if err := writeFile(path, "blkio.weight_device", c.BlkioWeightDevice); err != nil {
return err
}
}
if c.BlkioThrottleReadBpsDevice != "" {
if err := w... | go | {
"resource": ""
} |
q171565 | execSetns | validation | func (p *setnsProcess) execSetns() error {
err := p.cmd.Start()
p.childPipe.Close()
if err != nil {
return newSystemError(err)
}
status, err := p.cmd.Process.Wait()
if err != nil {
p.cmd.Wait()
return newSystemError(err)
}
if !status.Success() {
p.cmd.Wait()
return newSystemError(&exec.ExitError{Proce... | go | {
"resource": ""
} |
q171566 | GetAllSubsystems | validation | func GetAllSubsystems() ([]string, error) {
f, err := os.Open("/proc/cgroups")
if err != nil {
return nil, err
}
defer f.Close()
subsystems := []string{}
s := bufio.NewScanner(f)
for s.Scan() {
if err := s.Err(); err != nil {
return nil, err
}
text := s.Text()
if text[0] != '#' {
parts := strin... | go | {
"resource": ""
} |
q171567 | GetThisCgroupDir | validation | func GetThisCgroupDir(subsystem string) (string, error) {
f, err := os.Open("/proc/self/cgroup")
if err != nil {
return "", err
}
defer f.Close()
return ParseCgroupFile(subsystem, f)
} | go | {
"resource": ""
} |
q171568 | Capture | validation | func Capture(userSkip int) Stacktrace {
var (
skip = userSkip + 1 // add one for our own function
frames []Frame
)
for i := skip; ; i++ {
pc, file, line, ok := runtime.Caller(i)
if !ok {
break
}
frames = append(frames, NewFrame(pc, file, line))
}
return Stacktrace{
Frames: frames,
}
} | go | {
"resource": ""
} |
q171569 | getCgroupParamUint | validation | func getCgroupParamUint(cgroupPath, cgroupFile string) (uint64, error) {
contents, err := ioutil.ReadFile(filepath.Join(cgroupPath, cgroupFile))
if err != nil {
return 0, err
}
return parseUint(strings.TrimSpace(string(contents)), 10, 64)
} | go | {
"resource": ""
} |
q171570 | GetAdditionalGroupsPath | validation | func GetAdditionalGroupsPath(additionalGroups []string, groupPath string) ([]int, error) {
groupReader, err := os.Open(groupPath)
if err != nil {
return nil, fmt.Errorf("Failed to open group file: %v", err)
}
defer groupReader.Close()
groups, err := ParseGroupFilter(groupReader, func(g Group) bool {
for _, ag... | go | {
"resource": ""
} |
q171571 | addArgsFromEnv | validation | func addArgsFromEnv(evar string, args *[]string) {
if e := os.Getenv(evar); e != "" {
for _, f := range strings.Fields(e) {
*args = append(*args, f)
}
}
fmt.Printf(">>> criu %v\n", *args)
} | go | {
"resource": ""
} |
q171572 | InitLabels | validation | func InitLabels(options []string) (string, string, error) {
if !selinux.SelinuxEnabled() {
return "", "", nil
}
processLabel, mountLabel := selinux.GetLxcContexts()
if processLabel != "" {
pcon := selinux.NewContext(processLabel)
mcon := selinux.NewContext(mountLabel)
for _, opt := range options {
if opt... | go | {
"resource": ""
} |
q171573 | SetFileLabel | validation | func SetFileLabel(path string, fileLabel string) error {
if selinux.SelinuxEnabled() && fileLabel != "" {
return selinux.Setfilecon(path, fileLabel)
}
return nil
} | go | {
"resource": ""
} |
q171574 | SetFileCreateLabel | validation | func SetFileCreateLabel(fileLabel string) error {
if selinux.SelinuxEnabled() {
return selinux.Setfscreatecon(fileLabel)
}
return nil
} | go | {
"resource": ""
} |
q171575 | Relabel | validation | func Relabel(path string, fileLabel string, relabel string) error {
exclude_path := []string{"/", "/usr", "/etc"}
if fileLabel == "" {
return nil
}
if !strings.ContainsAny(relabel, "zZ") {
return nil
}
for _, p := range exclude_path {
if path == p {
return fmt.Errorf("Relabeling of %s is not allowed", pa... | go | {
"resource": ""
} |
q171576 | NetworkGetRoutes | validation | func NetworkGetRoutes() ([]Route, error) {
s, err := getNetlinkSocket()
if err != nil {
return nil, err
}
defer s.Close()
wb := newNetlinkRequest(syscall.RTM_GETROUTE, syscall.NLM_F_DUMP)
msg := newIfInfomsg(syscall.AF_UNSPEC)
wb.AddData(msg)
if err := s.Send(wb); err != nil {
return nil, err
}
pid, e... | go | {
"resource": ""
} |
q171577 | CreateBridge | validation | func CreateBridge(name string, setMacAddr bool) error {
if len(name) >= IFNAMSIZ {
return fmt.Errorf("Interface name %s too long", name)
}
s, err := getIfSocket()
if err != nil {
return err
}
defer syscall.Close(s)
nameBytePtr, err := syscall.BytePtrFromString(name)
if err != nil {
return err
}
if _, ... | go | {
"resource": ""
} |
q171578 | DeleteBridge | validation | func DeleteBridge(name string) error {
s, err := getIfSocket()
if err != nil {
return err
}
defer syscall.Close(s)
nameBytePtr, err := syscall.BytePtrFromString(name)
if err != nil {
return err
}
var ifr ifreqFlags
copy(ifr.IfrnName[:len(ifr.IfrnName)-1], []byte(name))
if _, _, err := syscall.Syscall(sy... | go | {
"resource": ""
} |
q171579 | AddToBridge | validation | func AddToBridge(iface, master *net.Interface) error {
return ifIoctBridge(iface, master, SIOC_BRADDIF)
} | go | {
"resource": ""
} |
q171580 | DelFromBridge | validation | func DelFromBridge(iface, master *net.Interface) error {
return ifIoctBridge(iface, master, SIOC_BRDELIF)
} | go | {
"resource": ""
} |
q171581 | labelIndex | validation | func labelIndex(labels *bpfLabels, lb string) uint32 {
var id uint32
for id = 0; id < uint32(len(*labels)); id++ {
if strings.EqualFold(lb, (*labels)[id].label) {
return id
}
}
*labels = append(*labels, bpfLabel{lb, 0xffffffff})
return id
} | go | {
"resource": ""
} |
q171582 | getSelinuxMountPoint | validation | func getSelinuxMountPoint() string {
if selinuxfs != "unknown" {
return selinuxfs
}
selinuxfs = ""
mounts, err := mount.GetMounts()
if err != nil {
return selinuxfs
}
for _, mount := range mounts {
if mount.Fstype == "selinuxfs" {
selinuxfs = mount.Mountpoint
break
}
}
if selinuxfs != "" {
var... | go | {
"resource": ""
} |
q171583 | SelinuxEnabled | validation | func SelinuxEnabled() bool {
if selinuxEnabledChecked {
return selinuxEnabled
}
selinuxEnabledChecked = true
if fs := getSelinuxMountPoint(); fs != "" {
if con, _ := Getcon(); con != "kernel" {
selinuxEnabled = true
}
}
return selinuxEnabled
} | go | {
"resource": ""
} |
q171584 | Setfilecon | validation | func Setfilecon(path string, scon string) error {
return system.Lsetxattr(path, xattrNameSelinux, []byte(scon), 0)
} | go | {
"resource": ""
} |
q171585 | Getfilecon | validation | func Getfilecon(path string) (string, error) {
con, err := system.Lgetxattr(path, xattrNameSelinux)
// Trim the NUL byte at the end of the byte buffer, if present.
if con[len(con)-1] == '\x00' {
con = con[:len(con)-1]
}
return string(con), err
} | go | {
"resource": ""
} |
q171586 | badPrefix | validation | func badPrefix(fpath string) error {
var badprefixes = []string{"/usr"}
for _, prefix := range badprefixes {
if fpath == prefix || strings.HasPrefix(fpath, fmt.Sprintf("%s/", prefix)) {
return fmt.Errorf("Relabeling content in %s is not allowed.", prefix)
}
}
return nil
} | go | {
"resource": ""
} |
q171587 | Chcon | validation | func Chcon(fpath string, scon string, recurse bool) error {
if scon == "" {
return nil
}
if err := badPrefix(fpath); err != nil {
return err
}
callback := func(p string, info os.FileInfo, err error) error {
return Setfilecon(p, scon)
}
if recurse {
return filepath.Walk(fpath, callback)
}
return Setfi... | go | {
"resource": ""
} |
q171588 | DupSecOpt | validation | func DupSecOpt(src string) []string {
if src == "" {
return nil
}
con := NewContext(src)
if con["user"] == "" ||
con["role"] == "" ||
con["type"] == "" ||
con["level"] == "" {
return nil
}
return []string{"label:user:" + con["user"],
"label:role:" + con["role"],
"label:type:" + con["type"],
"label... | go | {
"resource": ""
} |
q171589 | attach | validation | func (v *veth) attach(n *configs.Network) (err error) {
bridge, err := net.InterfaceByName(n.Bridge)
if err != nil {
return err
}
host, err := net.InterfaceByName(n.HostInterfaceName)
if err != nil {
return err
}
if err := netlink.AddToBridge(host, bridge); err != nil {
return err
}
if err := netlink.Net... | go | {
"resource": ""
} |
q171590 | Add | validation | func (c *Context) Add(s *Syscall) {
c.syscalls[s.Value] = s
} | go | {
"resource": ""
} |
q171591 | Load | validation | func (c *Context) Load() error {
filter, err := c.newFilter()
if err != nil {
return err
}
if err := prctl(prSetNoNewPrivileges, 1, 0, 0, 0); err != nil {
return err
}
prog := newSockFprog(filter)
return prog.set()
} | go | {
"resource": ""
} |
q171592 | newGraph | validation | func newGraph() *graph {
return &graph{
idToNodes: make(map[ID]Node),
nodeToSources: make(map[ID]map[ID]float64),
nodeToTargets: make(map[ID]map[ID]float64),
//
// without this
// panic: assignment to entry in nil map
}
} | go | {
"resource": ""
} |
q171593 | MakeDisjointSet | validation | func MakeDisjointSet(forests *Forests, name string) {
newDS := &DisjointSet{}
newDS.represent = name
members := make(map[string]struct{})
members[name] = struct{}{}
newDS.members = members
forests.mu.Lock()
defer forests.mu.Unlock()
forests.data[newDS] = struct{}{}
} | go | {
"resource": ""
} |
q171594 | FindSet | validation | func FindSet(forests *Forests, name string) *DisjointSet {
forests.mu.Lock()
defer forests.mu.Unlock()
for data := range forests.data {
if data.represent == name {
return data
}
for k := range data.members {
if k == name {
return data
}
}
}
return nil
} | go | {
"resource": ""
} |
q171595 | Union | validation | func Union(forests *Forests, ds1, ds2 *DisjointSet) {
newDS := &DisjointSet{}
newDS.represent = ds1.represent
newDS.members = ds1.members
for k := range ds2.members {
newDS.members[k] = struct{}{}
}
forests.mu.Lock()
defer forests.mu.Unlock()
forests.data[newDS] = struct{}{}
delete(forests.data, ds1)
delete... | go | {
"resource": ""
} |
q171596 | Me | validation | func (c *Client) Me() (*User, error) {
user := &User{}
err := c.request("GET", "me", user, nil, nil)
if err != nil {
return nil, err
}
return user, nil
} | go | {
"resource": ""
} |
q171597 | ListProjects | validation | func (c *Client) ListProjects() ([]*Project, error) {
projects := []*Project{}
err := c.request("GET", "projects", &projects, nil, nil)
if err != nil {
return nil, err
}
for _, project := range projects {
if err := cleanupProject(project); err != nil {
return nil, err
}
}
return projects, nil
} | go | {
"resource": ""
} |
q171598 | DisableProject | validation | func (c *Client) DisableProject(account, repo string) error {
return c.request("DELETE", fmt.Sprintf("project/%s/%s/enable", account, repo), nil, nil, nil)
} | go | {
"resource": ""
} |
q171599 | FollowProject | validation | func (c *Client) FollowProject(account, repo string) (*Project, error) {
project := &Project{}
err := c.request("POST", fmt.Sprintf("project/%s/%s/follow", account, repo), project, nil, nil)
if err != nil {
return nil, err
}
if err := cleanupProject(project); err != nil {
return nil, err
}
return project,... | go | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.