adevtool/src/selinux/seapp.ts
2021-11-23 20:14:09 -08:00

28 lines
647 B
TypeScript

import { parseLines } from '../util/parse'
export interface SeappContext {
user: string
seinfo?: string
isPrivApp?: boolean
name: string
domain: string
type?: string
levelFrom: string
}
export function parseSeappContexts(seappContexts: string) {
let contexts = []
for (let line of parseLines(seappContexts)) {
// Parse key-value fields
let rawContext: { [key: string]: string } = {}
for (let kv of line.trim().split(/\s+/)) {
let [key, value] = kv.split('=')
rawContext[key] = value
}
// Cast directly to object
contexts.push(rawContext as unknown as SeappContext)
}
return contexts
}