This file is indexed.

/usr/share/luasandbox/modules/lpeg/cbufd.lua is in lua-sandbox-extensions 0~git20161128-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
-- This Source Code Form is subject to the terms of the Mozilla Public
-- License, v. 2.0. If a copy of the MPL was not distributed with this
-- file, You can obtain one at http://mozilla.org/MPL/2.0/.

--[[
# Circular Buffer Delta Module

## Variables

* `grammar` - LPEG grammar to parse cbufd output

## Usage
```lua
local cbufd = require "lpeg.cbufd".grammar

function process_message()
    local payload = read_message("Payload")
    local t = cbufd:match(payload)
    if not t then
        return -1, "invalid cbufd string"
    end
    -- use t
    return 0
end
```

## Sample Input/Output

### Circular Buffer Delta Input
```
{"time":1379574900,"rows":1440,"columns":2,"seconds_per_row":60,"column_info":[{"name":"Requests","unit":"count","aggregation":"sum"},{"name":"Total_Size","unit":"KiB","aggregation":"sum"}]}
1379660520      12075   159901
1379660280      11837   154880
```

### Lua Table Output
```lua
{
header='{"time":1379574900,"rows":1440,"columns":2,"seconds_per_row":60,"column_info":[{"name":"Requests","unit":"count","aggregation":"sum"},{"name":"Total_Size","unit":"KiB","aggregation":"sum"}]}',
{12075, 159901, time = 1379660520000000000},
{11837, 154880, time = 1379660280000000000}
}
```
--]]

-- Imports
local l = require "lpeg"
l.locale(l)
local tonumber = tonumber

local M = {}
setfenv(1, M) -- Remove external access to contain everything in the module

local function not_a_number()
    return 0/0
end

local eol = l.P"\n"
local header = l.Cg((1 - eol)^1, "header") * eol
local timestamp = l.digit^1 / "%0000000000" / tonumber
local sign = l.P"-"
local float = l.digit^1 * "." * l.digit^1
local nan = l.P"nan" / not_a_number
local number = (sign^-1 * (float + l.digit^1)) / tonumber
+ nan
local row = l.Ct(l.Cg(timestamp, "time") * ("\t" * number)^1 * eol)

grammar = l.Ct(header * row^1) * -1

return M