-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
143 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Security Policy | ||
|
||
## Supported Versions | ||
|
||
Use this section to tell people about which versions of your project are | ||
currently being supported with security updates. | ||
|
||
| Version | Supported | Remark | | ||
| ------- | ------------------ | ------ | | ||
| 3.0.x | :white_check_mark: | Current development release | | ||
| 2.1.x | :white_check_mark: | Stable release - security fixes only | | ||
| 2.0.x | :x: | Previous stable release - unsupported | | ||
| 1.x | :x: | Unsupported | | ||
|
||
## Reporting a Vulnerability | ||
|
||
Please [open an issue](https://github.com/paulgear/ntpmon/issues/new). At the | ||
moment I can see no need to create private issues for security flaws. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
^,*,130.95.128.58,3,10,377,167,0.000076249,0.000156259,0.011293960 | ||
=,-,130.95.13.18,4,10,377,904,0.000112006,0.000183676,0.055506174 | ||
^,-,203.0.178.191,2,10,377,29,0.002167636,0.002167636,0.132863492 | ||
^,-,110.141.196.84,1,10,377,343,0.004494720,0.004572738,0.027861051 | ||
^,-,203.114.73.24,2,10,177,365,0.002114314,0.002192088,0.097485669 | ||
^,-,120.146.26.214,2,10,377,1313,0.000196896,0.000535064,0.068387702 | ||
^,-,128.199.123.83,2,10,377,371,-0.021903355,-0.021825654,0.323896408 | ||
^,-,139.99.107.37,2,10,337,154,-0.020766487,-0.020766487,0.103270806 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# | ||
# Copyright: (c) 2023 Paul D. Gear | ||
# License: AGPLv3 <http://www.gnu.org/licenses/agpl.html> | ||
|
||
import pytest | ||
|
||
import line_protocol | ||
|
||
|
||
def test_escape_tag_value() -> None: | ||
assert line_protocol.escape_tag_value("hello=world") == "hello\\=world" | ||
assert line_protocol.escape_tag_value("hello world") == "hello\\ world" | ||
assert line_protocol.escape_tag_value("hello, world") == "hello\\,\\ world" | ||
|
||
|
||
def test_timestamp_to_line_protocol() -> None: | ||
assert line_protocol.timestamp_to_line_protocol(1) == (1, 0) | ||
assert line_protocol.timestamp_to_line_protocol(1.123_456_789) == (1, 123_456_789) | ||
assert line_protocol.timestamp_to_line_protocol(1.9) == (1, 900_000_000) | ||
assert line_protocol.timestamp_to_line_protocol(1.999) == (1, 999_000_000) | ||
assert line_protocol.timestamp_to_line_protocol(1.999_999) == (1, 999_999_000) | ||
assert line_protocol.timestamp_to_line_protocol(1.999_999_999) == (1, 999_999_999) | ||
with pytest.raises(ValueError): | ||
# We should never get to either of these assert statements - the | ||
# ValueError should be raised first. | ||
assert line_protocol.timestamp_to_line_protocol(-1) == (-1, 0) | ||
assert False | ||
|
||
|
||
def test_to_line_protocol() -> None: | ||
metrics = { | ||
"associd": 0, | ||
"frequency": -11.673, | ||
"leap": False, | ||
"offset": +0.0000145826, | ||
"precision": -23, | ||
"processor": "x86_64", | ||
"refid": "100.66.246.50", | ||
"reftime": "e93a0505.8336edfd", | ||
"rootdelay": 1.026, | ||
"rootdisp": 8.218, | ||
"stratum": 2, | ||
"sys jitter": 0.082849, | ||
"system": "Linux/5.10.0-26-amd64", | ||
"test": True, | ||
"version": "ntpd 4.2.8p15@1.3728-o Wed Sep 23 11:46:38 UTC 2020 (1)", | ||
} | ||
assert ( | ||
line_protocol.to_line_protocol(metrics, "ntpmon", additional_tags={"hostname": "ntp1", "processor": "amd64"}) | ||
== "ntpmon,hostname=ntp1,processor=x86_64,refid=100.66.246.50,reftime=e93a0505.8336edfd,system=Linux/5.10.0-26-amd64," | ||
"version=ntpd\\ 4.2.8p15@1.3728-o\\ Wed\\ Sep\\ 23\\ 11:46:38\\ UTC\\ 2020\\ (1) " | ||
"frequency=-11.673,offset=1.45826e-05,rootdelay=1.026,rootdisp=8.218," | ||
"sys_jitter=0.082849,associd=0i,precision=-23i,stratum=2i,leap=0i,test=1i" | ||
) | ||
|
||
|
||
def test_transform_identifier() -> None: | ||
assert line_protocol.transform_identifier("_chrony") == "chrony" | ||
assert line_protocol.transform_identifier("-chrony-was-here-") == "chrony_was_here" | ||
assert line_protocol.transform_identifier("hello, world") == "hello_world" | ||
assert line_protocol.transform_identifier("a = hello(world)") == "a_hello_world" | ||
assert line_protocol.transform_identifier("def hello(world) -> str:") == "def_hello_world_str" |