puppet-sec-lint 0.5.3 → 0.5.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.idea/puppet-sec-lint.iml +5 -7
- data/Gemfile +1 -1
- data/Gemfile.lock +3 -9
- data/docs/Gemfile.lock +3 -3
- data/docs/_config.yml +2 -6
- data/docs/_site/404.html +2 -2
- data/docs/_site/feed.xml +1 -1
- data/docs/_site/images/puppet-sec-lint_console.png +0 -0
- data/docs/_site/images/puppet-sec-lint_vscode.png +0 -0
- data/docs/_site/jekyll/update/2021/05/03/welcome-to-jekyll.html +2 -2
- data/docs/admin-by-default.md +27 -0
- data/docs/cyrillic-homograph-attack.md +40 -0
- data/docs/empty-password.md +27 -0
- data/docs/hard-coded-credentials.md +69 -6
- data/docs/invalid-ip-addr-binding.md +31 -0
- data/docs/weak-crypto-algorithm.md +31 -0
- data/exe/puppet-sec-lint +3 -0
- data/lib/lol.pp +6 -6
- data/lib/puppet-sec-lint/version.rb +1 -1
- data/lib/servers/language_server.rb +0 -2
- data/lib/servers/linter_server.rb +1 -4
- data/lib/settings.ini +2 -2
- data/puppet-sec-lint.gemspec +6 -7
- metadata +9 -21
- data/file.pp +0 -77
- data/lib/test.txt +0 -15
- data/lib/test2.rb +0 -16
- data/lib/test3.rb +0 -32
- data/lib/test_new.rb +0 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 844e10fd83efbd1c88d6347db5efefa488118e636da85ccb16354e0176d95465
|
4
|
+
data.tar.gz: 0eca06adb099f34d833d581bffc019cfd8ad61153c2cffd53b3f6d70709f706e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2150f2863771a997167858fb75561b848671788047d09bf8ef0dccde18f77d8756851ddfd68a2b94fb2dc096ce089465b7377a6270a1aed9d2786d1fd8b525d6
|
7
|
+
data.tar.gz: c33d424d3f105db9d88be69ce103263dbbaf1da1ecc4648d4b5bd06bfede2d9ee18de4d491d71104e9db93d1cd73177f2feb7bcf1e911bc98dafaeea23629ac7
|
data/.idea/puppet-sec-lint.iml
CHANGED
@@ -13,8 +13,6 @@
|
|
13
13
|
<orderEntry type="sourceFolder" forTests="false" />
|
14
14
|
<orderEntry type="library" scope="PROVIDED" name="addressable (v2.7.0, RVM: ruby-3.0.0 [global]) [gem]" level="application" />
|
15
15
|
<orderEntry type="library" scope="PROVIDED" name="bundler (v2.2.3, RVM: ruby-3.0.0 [global]) [gem]" level="application" />
|
16
|
-
<orderEntry type="library" scope="PROVIDED" name="daemons (v1.3.1, RVM: ruby-3.0.0 [global]) [gem]" level="application" />
|
17
|
-
<orderEntry type="library" scope="PROVIDED" name="eventmachine (v1.2.7, RVM: ruby-3.0.0 [global]) [gem]" level="application" />
|
18
16
|
<orderEntry type="library" scope="PROVIDED" name="inifile (v3.0.0, RVM: ruby-3.0.0 [global]) [gem]" level="application" />
|
19
17
|
<orderEntry type="library" scope="PROVIDED" name="launchy (v2.5.0, RVM: ruby-3.0.0 [global]) [gem]" level="application" />
|
20
18
|
<orderEntry type="library" scope="PROVIDED" name="minitest (v5.14.4, RVM: ruby-3.0.0 [global]) [gem]" level="application" />
|
@@ -22,22 +20,22 @@
|
|
22
20
|
<orderEntry type="library" scope="PROVIDED" name="puppet-lint (v2.4.2, RVM: ruby-3.0.0 [global]) [gem]" level="application" />
|
23
21
|
<orderEntry type="library" scope="PROVIDED" name="rack (v2.2.3, RVM: ruby-3.0.0 [global]) [gem]" level="application" />
|
24
22
|
<orderEntry type="library" scope="PROVIDED" name="rake (v13.0.3, RVM: ruby-3.0.0 [global]) [gem]" level="application" />
|
25
|
-
<orderEntry type="library" scope="PROVIDED" name="
|
23
|
+
<orderEntry type="library" scope="PROVIDED" name="webrick (v1.7.0, RVM: ruby-3.0.0 [global]) [gem]" level="application" />
|
26
24
|
</component>
|
27
25
|
<component name="RakeTasksCache">
|
28
26
|
<option name="myRootTask">
|
29
27
|
<RakeTaskImpl id="rake">
|
30
28
|
<subtasks>
|
31
|
-
<RakeTaskImpl description="Build puppet-sec-lint-0.
|
29
|
+
<RakeTaskImpl description="Build puppet-sec-lint-0.5.7.gem into the pkg directory" fullCommand="build" id="build" />
|
32
30
|
<RakeTaskImpl description="Remove any temporary products" fullCommand="clean" id="clean" />
|
33
31
|
<RakeTaskImpl description="Remove any generated files" fullCommand="clobber" id="clobber" />
|
34
|
-
<RakeTaskImpl description="Build and install puppet-sec-lint-0.
|
32
|
+
<RakeTaskImpl description="Build and install puppet-sec-lint-0.5.7.gem into system gems" fullCommand="install" id="install" />
|
35
33
|
<RakeTaskImpl id="install">
|
36
34
|
<subtasks>
|
37
|
-
<RakeTaskImpl description="Build and install puppet-sec-lint-0.
|
35
|
+
<RakeTaskImpl description="Build and install puppet-sec-lint-0.5.7.gem into system gems without network access" fullCommand="install:local" id="local" />
|
38
36
|
</subtasks>
|
39
37
|
</RakeTaskImpl>
|
40
|
-
<RakeTaskImpl description="Create tag v0.
|
38
|
+
<RakeTaskImpl description="Create tag v0.5.7 and build and push puppet-sec-lint-0.5.7.gem to https://rubygems.org" fullCommand="release[remote]" id="release[remote]" />
|
41
39
|
<RakeTaskImpl description="Run tests" fullCommand="test" id="test" />
|
42
40
|
<RakeTaskImpl description="" fullCommand="default" id="default" />
|
43
41
|
<RakeTaskImpl description="" fullCommand="release" id="release" />
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,22 +1,19 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
puppet-sec-lint (0.5.
|
4
|
+
puppet-sec-lint (0.5.7)
|
5
5
|
inifile (~> 3.0.0)
|
6
6
|
launchy (~> 2.5.0)
|
7
7
|
minitest (~> 5.0)
|
8
8
|
puppet-lint (~> 2.4, >= 2.4.2)
|
9
9
|
rack (~> 2.2.3)
|
10
10
|
rake (~> 13.0)
|
11
|
-
thin (~> 1.8.0)
|
12
11
|
|
13
12
|
GEM
|
14
13
|
remote: https://rubygems.org/
|
15
14
|
specs:
|
16
15
|
addressable (2.7.0)
|
17
16
|
public_suffix (>= 2.0.2, < 5.0)
|
18
|
-
daemons (1.3.1)
|
19
|
-
eventmachine (1.2.7)
|
20
17
|
inifile (3.0.0)
|
21
18
|
launchy (2.5.0)
|
22
19
|
addressable (~> 2.7)
|
@@ -25,10 +22,7 @@ GEM
|
|
25
22
|
puppet-lint (2.4.2)
|
26
23
|
rack (2.2.3)
|
27
24
|
rake (13.0.3)
|
28
|
-
|
29
|
-
daemons (~> 1.0, >= 1.0.9)
|
30
|
-
eventmachine (~> 1.0, >= 1.0.4)
|
31
|
-
rack (>= 1, < 3)
|
25
|
+
webrick (1.7.0)
|
32
26
|
|
33
27
|
PLATFORMS
|
34
28
|
x86_64-linux
|
@@ -41,7 +35,7 @@ DEPENDENCIES
|
|
41
35
|
puppet-sec-lint!
|
42
36
|
rack
|
43
37
|
rake (~> 13.0)
|
44
|
-
|
38
|
+
webrick
|
45
39
|
|
46
40
|
BUNDLED WITH
|
47
41
|
2.2.3
|
data/docs/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
GEM
|
2
2
|
remote: https://rubygems.org/
|
3
3
|
specs:
|
4
|
-
activesupport (6.0.3.
|
4
|
+
activesupport (6.0.3.7)
|
5
5
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
6
6
|
i18n (>= 0.7, < 2)
|
7
7
|
minitest (~> 5.1)
|
@@ -25,7 +25,7 @@ GEM
|
|
25
25
|
ethon (0.14.0)
|
26
26
|
ffi (>= 1.15.0)
|
27
27
|
eventmachine (1.2.7)
|
28
|
-
execjs (2.
|
28
|
+
execjs (2.8.0)
|
29
29
|
faraday (1.4.1)
|
30
30
|
faraday-excon (~> 1.1)
|
31
31
|
faraday-net_http (~> 1.0)
|
@@ -228,7 +228,7 @@ GEM
|
|
228
228
|
forwardable-extended (~> 2.6)
|
229
229
|
public_suffix (4.0.6)
|
230
230
|
racc (1.5.2)
|
231
|
-
rb-fsevent (0.
|
231
|
+
rb-fsevent (0.11.0)
|
232
232
|
rb-inotify (0.10.1)
|
233
233
|
ffi (~> 1.0)
|
234
234
|
rexml (3.2.5)
|
data/docs/_config.yml
CHANGED
@@ -13,14 +13,10 @@
|
|
13
13
|
# you will see them accessed via {{ site.title }}, {{ site.email }}, and so on.
|
14
14
|
# You can create any custom variable you would like, and they will be accessible
|
15
15
|
# in the templates via {{ site.myvariable }}.
|
16
|
-
title: Puppet
|
16
|
+
title: Puppet Security Linter
|
17
17
|
email: tiago7b27@gmail.com
|
18
18
|
description: >- # this means to ignore newlines until "baseurl:"
|
19
|
-
|
20
|
-
baseurl: "" # the subpath of your site, e.g. /blog
|
21
|
-
url: "" # the base hostname & protocol for your site, e.g. http://example.com
|
22
|
-
twitter_username: jekyllrb
|
23
|
-
github_username: jekyll
|
19
|
+
Security focused linter to detect and help solve vulnerabilities found on Puppet Infrastructure-as-code scripts
|
24
20
|
|
25
21
|
# Build settings
|
26
22
|
markdown: kramdown
|
data/docs/_site/404.html
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
<meta charset='utf-8'>
|
5
5
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
6
6
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
7
|
-
<link rel="stylesheet" href="/assets/css/style.css?v=
|
7
|
+
<link rel="stylesheet" href="/assets/css/style.css?v=b8f4fcea6993188f9bfaf6d72181f63f9e7a5872">
|
8
8
|
|
9
9
|
<!-- Begin Jekyll SEO tag v2.7.1 -->
|
10
10
|
<title>Puppet Securtiy Linter | Scurity focused linter to detect and help solve vulnearbilities found on Puppet Infrastructure-as-code scripts</title>
|
@@ -19,7 +19,7 @@
|
|
19
19
|
<meta name="twitter:card" content="summary" />
|
20
20
|
<meta property="twitter:title" content="Puppet Securtiy Linter" />
|
21
21
|
<script type="application/ld+json">
|
22
|
-
{"
|
22
|
+
{"headline":"Puppet Securtiy Linter","description":"Scurity focused linter to detect and help solve vulnearbilities found on Puppet Infrastructure-as-code scripts","url":"http://localhost:4000/404.html","@type":"WebPage","@context":"https://schema.org"}</script>
|
23
23
|
<!-- End Jekyll SEO tag -->
|
24
24
|
|
25
25
|
</head>
|
data/docs/_site/feed.xml
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.9.0">Jekyll</generator><link href="http://localhost:4000/feed.xml" rel="self" type="application/atom+xml" /><link href="http://localhost:4000/" rel="alternate" type="text/html" /><updated>2021-05-
|
1
|
+
<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.9.0">Jekyll</generator><link href="http://localhost:4000/feed.xml" rel="self" type="application/atom+xml" /><link href="http://localhost:4000/" rel="alternate" type="text/html" /><updated>2021-05-13T01:19:00+01:00</updated><id>http://localhost:4000/feed.xml</id><title type="html">Puppet Securtiy Linter</title><subtitle>Scurity focused linter to detect and help solve vulnearbilities found on Puppet Infrastructure-as-code scripts</subtitle><entry><title type="html">Welcome to Jekyll!</title><link href="http://localhost:4000/jekyll/update/2021/05/03/welcome-to-jekyll.html" rel="alternate" type="text/html" title="Welcome to Jekyll!" /><published>2021-05-03T21:09:12+01:00</published><updated>2021-05-03T21:09:12+01:00</updated><id>http://localhost:4000/jekyll/update/2021/05/03/welcome-to-jekyll</id><content type="html" xml:base="http://localhost:4000/jekyll/update/2021/05/03/welcome-to-jekyll.html"><p>You’ll find this post in your <code class="language-plaintext highlighter-rouge">_posts</code> directory. Go ahead and edit it and re-build the site to see your changes. You can rebuild the site in many different ways, but the most common way is to run <code class="language-plaintext highlighter-rouge">jekyll serve</code>, which launches a web server and auto-regenerates your site when a file is updated.</p>
|
2
2
|
|
3
3
|
<p>To add new posts, simply add a file in the <code class="language-plaintext highlighter-rouge">_posts</code> directory that follows the convention <code class="language-plaintext highlighter-rouge">YYYY-MM-DD-name-of-post.ext</code> and includes the necessary front matter. Take a look at the source for this post to get an idea about how it works.</p>
|
4
4
|
|
Binary file
|
Binary file
|
@@ -4,7 +4,7 @@
|
|
4
4
|
<meta charset='utf-8'>
|
5
5
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
6
6
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
7
|
-
<link rel="stylesheet" href="/assets/css/style.css?v=
|
7
|
+
<link rel="stylesheet" href="/assets/css/style.css?v=b8f4fcea6993188f9bfaf6d72181f63f9e7a5872">
|
8
8
|
|
9
9
|
<!-- Begin Jekyll SEO tag v2.7.1 -->
|
10
10
|
<title>Welcome to Jekyll! | Puppet Securtiy Linter</title>
|
@@ -21,7 +21,7 @@
|
|
21
21
|
<meta name="twitter:card" content="summary" />
|
22
22
|
<meta property="twitter:title" content="Welcome to Jekyll!" />
|
23
23
|
<script type="application/ld+json">
|
24
|
-
{"
|
24
|
+
{"headline":"Welcome to Jekyll!","dateModified":"2021-05-03T21:09:12+01:00","datePublished":"2021-05-03T21:09:12+01:00","description":"You’ll find this post in your _posts directory. Go ahead and edit it and re-build the site to see your changes. You can rebuild the site in many different ways, but the most common way is to run jekyll serve, which launches a web server and auto-regenerates your site when a file is updated.","url":"http://localhost:4000/jekyll/update/2021/05/03/welcome-to-jekyll.html","@type":"BlogPosting","mainEntityOfPage":{"@type":"WebPage","@id":"http://localhost:4000/jekyll/update/2021/05/03/welcome-to-jekyll.html"},"@context":"https://schema.org"}</script>
|
25
25
|
<!-- End Jekyll SEO tag -->
|
26
26
|
|
27
27
|
</head>
|
@@ -0,0 +1,27 @@
|
|
1
|
+
---
|
2
|
+
title: Admin by default
|
3
|
+
permalink: /admin-by-default/
|
4
|
+
layout: default
|
5
|
+
---
|
6
|
+
|
7
|
+
# Admin by default
|
8
|
+
|
9
|
+
## What is it?
|
10
|
+
|
11
|
+
An user who is created with administrator privileges usually has permission to do everything in the system. It's usually identified with the username 'admin' in a lot of software applications.
|
12
|
+
|
13
|
+
### Example
|
14
|
+
```puppet
|
15
|
+
user { 'admin':
|
16
|
+
ensure => 'present'
|
17
|
+
}
|
18
|
+
```
|
19
|
+
This user, with the username 'admin', will likely have a big concentration of privileges by default.
|
20
|
+
|
21
|
+
## How can it be exploited?
|
22
|
+
|
23
|
+
Any account with the power to do everything in the system is a very dangerous single point of failure. Firstly, even during normal operations, it allows for its user to potentially change the system in unwanted ways, or even access information that he's not supposed to. Even worse, it presents a very dangerous point of entry for an attacker, as he just needs to compromise this single password to have complete access to the system.
|
24
|
+
|
25
|
+
## How to avoid it?
|
26
|
+
|
27
|
+
Accounts should always be setup up with the [Principle of least privilege](https://us-cert.cisa.gov/bsi/articles/knowledge/principles/least-privilege) in mind, meaning that all accounts should only get the permissions strictly necessary to perform their required tasks during the minimum amount of time possible. This severely limits the exposure to accidental errors and also to malicious attackers.
|
@@ -0,0 +1,40 @@
|
|
1
|
+
---
|
2
|
+
title: Cyrillic Homograph Attack
|
3
|
+
permalink: /cyrillic-homograph-attack/
|
4
|
+
layout: default
|
5
|
+
---
|
6
|
+
|
7
|
+
# Cyrillic Homograph Attack
|
8
|
+
|
9
|
+
## What are they?
|
10
|
+
|
11
|
+
A Cyrillic Homograph attack takes advantage of the fact that several characters in the [Cyrillic alphabet](https://www.britannica.com/topic/Cyrillic-alphabet) are virtually indistinguishable (homographs) from regular Latin ones in a lot of fonts. This makes it possible for attackers to setup fake domains with Cyrillic characters that look identical to the real one but redirect the user to a malicious website.
|
12
|
+
|
13
|
+
### Example
|
14
|
+
These two website links look identical:
|
15
|
+
```
|
16
|
+
https://google.com
|
17
|
+
https://gооgle.com
|
18
|
+
```
|
19
|
+
|
20
|
+
But after taking a closer look at the code of each character of the website name only, it's possible to see where the attack can be made:
|
21
|
+
```
|
22
|
+
\u0067 \u006f \u006f \u0067 \u006c \u0065 \u002e \u0063 \u006f \u006d
|
23
|
+
\u0067 \u043e \u043e \u0067 \u006c \u0065 \u002e \u0063 \u006f \u006d
|
24
|
+
g o o g l e . c o m
|
25
|
+
```
|
26
|
+
|
27
|
+
It's possible to see that the second and third characters in the word "google" are different. On the top domain, the Latin o letter is used (unicode u006f) but on the bottom one, the Cyrillic о letter is used (unicode u043e). Although similar, the bottom website can point to a completely different server.
|
28
|
+
|
29
|
+
## How can it be exploited?
|
30
|
+
|
31
|
+
To exploit this vulnerability, an attacker can setup, for example, a malicious software repository and register a domain that looks exactly like an existing legitimate one, but written with Cyrillic characters. It's even possible to request a SSL certificate for it, making it possible to receive HTTPS connections, further convincing the user of its authenticity.
|
32
|
+
|
33
|
+
This malicious domain on a Puppet manifest can point to a fake package repository, containing malware infected versions of legitimate packages. These malicious packages would then be installed in all infrastructure deployed by that manifest, causing a widespread infection that could severely compromise the integrity of the systems.
|
34
|
+
|
35
|
+
## How to avoid it?
|
36
|
+
|
37
|
+
After the tool detects the presence of Cyrillic characters on a URL, the best course of action is to replace all Cyrillic characters with their Latin counterparts, as these characters are very rarely used in legitimate domains.
|
38
|
+
Then, check if the domain is well written (subtle misspellings with similar letters are very common in these kinds of attacks).
|
39
|
+
|
40
|
+
To better ensure that the domain is actually the correct one, the URL can also be copied from a trusted source.
|
@@ -0,0 +1,27 @@
|
|
1
|
+
---
|
2
|
+
title: Empty Password
|
3
|
+
permalink: /empty-password/
|
4
|
+
layout: default
|
5
|
+
---
|
6
|
+
|
7
|
+
# Empty password
|
8
|
+
|
9
|
+
## What are they?
|
10
|
+
|
11
|
+
An account with an empty password is different from an account with no password. Here, the password exists, it's prompted but it's an empty string.
|
12
|
+
|
13
|
+
### Example
|
14
|
+
If an account has an empty password, when logging in, the user should still be prompted fo input the password:
|
15
|
+
```
|
16
|
+
Password:
|
17
|
+
```
|
18
|
+
|
19
|
+
But a simple click on the return key, without actually writing anything, is enough to log in.
|
20
|
+
|
21
|
+
## How can it be exploited?
|
22
|
+
|
23
|
+
An attacker looking to gain access to an account my try a couple of different generic and vulnerable passwords to brute force his way in. One of his first attempts may be to just press return without actually writing anything. This makes for a very easy password to be guessed.
|
24
|
+
|
25
|
+
## How to avoid it?
|
26
|
+
|
27
|
+
Secure software systems should have a decent password policy that prevents, among other types, empty passwords. This means that it's very likely for the Puppet manifest to fail as the password would be rejected. But even if the target software accepts empty passwords, a long and hard to guess password is always a much safer option against malicious attacks.
|
@@ -1,17 +1,80 @@
|
|
1
1
|
---
|
2
2
|
title: Hard Coded Credentials
|
3
3
|
permalink: /hard-coded-credentials/
|
4
|
+
layout: default
|
4
5
|
---
|
5
6
|
|
6
7
|
# Hard Coded Credentials
|
7
8
|
|
8
|
-
|
9
|
+
## What are they?
|
9
10
|
|
10
|
-
|
11
|
+
Hard Coded credentials are sensitive information, like passwords, private keys and other secrets, that are written directly on the source code, in plain text.
|
12
|
+
### Examples
|
13
|
+
Username and password for a mysql database:
|
14
|
+
```puppet
|
15
|
+
mysql::user { 'pdns':
|
16
|
+
password => 'pdns123pass',
|
17
|
+
requires => Mysql::Database['pdns'];
|
18
|
+
}
|
19
|
+
```
|
11
20
|
|
21
|
+
Private key used to access a database:
|
12
22
|
```puppet
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
23
|
+
file { '/etc/mysql/server-key.pem':
|
24
|
+
ensure => file,
|
25
|
+
content => '-----BEGIN RSA PRIVATE KEY-----
|
26
|
+
MIIEpAIBAAKCAQEA9bftj7SJfMpBqk7eza3I1Tp4n3VbjkEo7pq9ft6hCpSHaThN
|
27
|
+
OU362GyeLawZNTCtROePj3g2StB3UFQTGRe5Xbl510UaoRwSpHnUSTaDfjPeT8SX
|
28
|
+
(...)
|
29
|
+
nh0c2NOM2YaGl1J0/WUnzsg7ZDMY6S9zQQ/KZP6LVm4P5yn3k8h8B9FL13a9AK83
|
30
|
+
89RotRTzKPEAh7SjI84GAVUn6BcxsrVroe3p45E9KpX1bgYCkvu45Q==
|
31
|
+
-----END RSA PRIVATE KEY-----',
|
32
|
+
}
|
33
|
+
```
|
34
|
+
|
35
|
+
## How can it be exploited?
|
36
|
+
|
37
|
+
Having hard coded credentials in code can expose the software to several kinds of vulnerabilities:
|
38
|
+
* If the puppet manifest is used to deploy several different machines, because the credentials are hard coded, all of them will share the same credentials. This make it possible for an attacker to exploit all machines after compromising just one of them.
|
39
|
+
* It's hard to manage and rotate secrets if these ever get compromised, as they can be distributed across several different manifests.
|
40
|
+
* If an attacker ever gets hold of the source code (by compromising the code repository or the local machine of one developer for example), he can easily access the credentials for potentially all machines in the system.
|
41
|
+
This is an even bigger problem if the source code is open source, as in that case the passwords are completely open to anyone to see them.
|
42
|
+
|
43
|
+
## How to avoid it?
|
44
|
+
|
45
|
+
There are much better ways to store credentials and other secrets. A fairly easy and secure way is by using a tool provided by Puppet called [Hiera](https://puppet.com/docs/puppet/7.6/hiera.html).
|
46
|
+
|
47
|
+
It allows the storage of credentials and other data in a centralized file, using then keys to reference them in the source code. This allows for an easy management of the passwords and the possibility of, for example, quickly rotating them between installations.
|
48
|
+
|
49
|
+
For even more security, [Hiera can use an encrypted file](https://puppet.com/blog/encrypt-your-data-using-hiera-eyaml/), protecting also against attackers who might, for example, gain access to the source code repository.
|
50
|
+
|
51
|
+
### Example
|
52
|
+
|
53
|
+
A **secrets.yaml** file containing the password:
|
54
|
+
|
55
|
+
```yaml
|
56
|
+
---
|
57
|
+
password: pdns123pass
|
58
|
+
privatekey: |-
|
59
|
+
-----BEGIN OPENSSH PRIVATE KEY-----
|
60
|
+
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAABFwAAAAdzc2gtcn
|
61
|
+
NhAAAAAwEAAQAAAQEAssBRe91wZ0TJBIWK2V1NH/ourcFPb0cA4ln32a3j5QITMS3zhs/o
|
62
|
+
(...)
|
63
|
+
C8YRNCLnBgR2CCp27D0wuadL9aFITlx91GPytF9BKxzy949VaF6SEw9M86oouj362u/BvP
|
64
|
+
CO7Hnjlg77HRNFXPAAAAFWxrYW1pcmVkZHlAdm13YXJlLmNvbQECAwQF
|
65
|
+
-----END OPENSSH PRIVATE KEY-----
|
17
66
|
```
|
67
|
+
|
68
|
+
And then the source code from the examples above, but now without hard coded credentials:
|
69
|
+
|
70
|
+
```puppet
|
71
|
+
mysql::user { 'pdns':
|
72
|
+
password => hiera("password"),
|
73
|
+
requires => Mysql::Database['pdns'];
|
74
|
+
}
|
75
|
+
|
76
|
+
file { '/etc/mysql/server-key.pem':
|
77
|
+
ensure => file,
|
78
|
+
content => hiera("privatekey"),
|
79
|
+
}
|
80
|
+
```
|
@@ -0,0 +1,31 @@
|
|
1
|
+
---
|
2
|
+
title: Invalid IP Address binding
|
3
|
+
permalink: /invalid-ip-addr-binding/
|
4
|
+
layout: default
|
5
|
+
---
|
6
|
+
|
7
|
+
# Invalid IP Address binding
|
8
|
+
|
9
|
+
## What it it?
|
10
|
+
|
11
|
+
Binding an IP address to a server or service means authorizing connections incoming from those networks. This allows to limit what kind of incoming connections a server may or may not accept. Binding the 0.0.0.0 IP address to a service means that any connection from any network is accepted.
|
12
|
+
|
13
|
+
### Example
|
14
|
+
Using Puppet to configure a MySQL database bind address:
|
15
|
+
```puppet
|
16
|
+
class { 'mysql::server':
|
17
|
+
config_hash => {
|
18
|
+
'bind_address' => '0.0.0.0'
|
19
|
+
}
|
20
|
+
}
|
21
|
+
```
|
22
|
+
This configuration means that the database accepts connections from anywhere, including remote clients if it's connected to the internet.
|
23
|
+
|
24
|
+
|
25
|
+
## How can it be exploited?
|
26
|
+
|
27
|
+
A server or service that's open to all kinds of connections it's more exposed to possible attacks coming from non intended networks. A malicious attacker can try to gain access to it just by using it's own network or other compromised networks across the globe.
|
28
|
+
|
29
|
+
## How to avoid it?
|
30
|
+
|
31
|
+
Properly configuring binding addresses means that the server should only accept connections from trusted networks known to use the service. This ensures a greater level of control and also protection, as an attacker would know have an extra obstacle in trying to gain access first to one of those networks.
|
@@ -0,0 +1,31 @@
|
|
1
|
+
---
|
2
|
+
title:
|
3
|
+
permalink: /weak-crypto-algorithm/
|
4
|
+
layout: default
|
5
|
+
---
|
6
|
+
|
7
|
+
# Use of weak Cryptographic algorithms
|
8
|
+
|
9
|
+
## What are they?
|
10
|
+
|
11
|
+
A Cryptographic hash algorithm is a one-way function used to map data to an unique fixed-sized sequence of bytes. This has several applications in CyberSecurity, like storing passwords securely in a server for example. The strength of an algorithm is measured by its ability to generate a truly unique output for every unique input and also by its ability to be non reversible, meaning that it should be impossible to determine the original value given the generated hash.
|
12
|
+
|
13
|
+
Weak algorithms like MD5 or SHA-1, either by their age or by their design flaws, are known to not ensure these properties.
|
14
|
+
|
15
|
+
### Example
|
16
|
+
The weakness of the SHA-1 algorithm was originally demonstrated with the collision shown on [this website](https://shattered.it):
|
17
|
+
|
18
|
+
```shell
|
19
|
+
$ sha1sum *.pdf
|
20
|
+
38762cf7f55934b34d179ae6a4c80cadccbb7f0a shattered-1.pdf
|
21
|
+
38762cf7f55934b34d179ae6a4c80cadccbb7f0a shattered-2.pdf
|
22
|
+
```
|
23
|
+
They have two different .pdf files that should generate two different hashes, but as shown above, the resulting hash is exactly the same.
|
24
|
+
|
25
|
+
## How can it be exploited?
|
26
|
+
|
27
|
+
An attacker who was able to gain access to a server and steal the hashes from all passwords may exploit the weaknesses on the hashing algorithm to either try to reverse them or perform a collision attack. This happens because the algorithm allows the existence of collisions, meaning that an attacker may be able to brute force an hash without even finding the original password.
|
28
|
+
|
29
|
+
## How to avoid it?
|
30
|
+
|
31
|
+
If the Puppet manifest is being used to generate hashes for passwords or important data, using a more secure algorithm like SHA256 is very advisable as it avoids exposure to the risks mentioned above, ensuring that the algorithm actually performs what's intended to.
|
data/exe/puppet-sec-lint
CHANGED
@@ -9,6 +9,9 @@ require_relative '../lib/puppet-sec-lint/version'
|
|
9
9
|
require_relative '../lib/visitors/configuration_visitor'
|
10
10
|
require_relative '../lib/facades/configuration_file_facade'
|
11
11
|
|
12
|
+
ConfigurationVisitor.GenerateIDs
|
13
|
+
ConfigurationFileFacade.LoadConfigurations
|
14
|
+
|
12
15
|
#get free port
|
13
16
|
loop do
|
14
17
|
$port = rand(3000..9999)
|
data/lib/lol.pp
CHANGED
@@ -8,17 +8,17 @@
|
|
8
8
|
# the following code addresses the bug: https://bugs.launchpad.net/keystone/+bug/1472285 .
|
9
9
|
|
10
10
|
class consul_template::service (
|
11
|
-
$
|
12
|
-
$
|
13
|
-
$
|
14
|
-
$
|
11
|
+
$rpc_password = '{6ad470ec62b0511b63340dca2950d750181598efnHKvN1ge',
|
12
|
+
$admin_username = 'admin',
|
13
|
+
$password = 'ceilometer',
|
14
|
+
$admin_password = 'admin',
|
15
15
|
) {
|
16
16
|
exec { 'network-restart':
|
17
17
|
command => 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDM release-runner key',
|
18
18
|
path => '/usr/bin:/usr/sbin:/bin:/sbin',
|
19
19
|
refreshonly => true,
|
20
20
|
vmware_md5 => 'LOL',
|
21
|
-
autho => '
|
21
|
+
autho => 'MD5',
|
22
22
|
cmd => 'virsh secret-define --file ${secret_xml} && virsh secret-set-value --secret ${rbd_secret_uuid} --base64 $(ceph auth get-key client.${user})',
|
23
23
|
$auth_uri => 'http://127.0.0.1:5000',
|
24
24
|
'bind_address' => '0.0.0.0',
|
@@ -80,4 +80,4 @@ UcXHbA==
|
|
80
80
|
replace => true,
|
81
81
|
require => File['/var/lib/gerrit/.ssh']
|
82
82
|
}
|
83
|
-
}
|
83
|
+
}
|
@@ -1,5 +1,4 @@
|
|
1
1
|
require "rack"
|
2
|
-
require "thin"
|
3
2
|
require 'json'
|
4
3
|
require 'uri'
|
5
4
|
require_relative '../rule_engine'
|
@@ -8,8 +7,6 @@ require_relative '../facades/configuration_page_facade'
|
|
8
7
|
require_relative '../facades/configuration_file_facade'
|
9
8
|
|
10
9
|
class LinterServer
|
11
|
-
ConfigurationVisitor.GenerateIDs
|
12
|
-
ConfigurationFileFacade.LoadConfigurations
|
13
10
|
|
14
11
|
def call(env)
|
15
12
|
req = Rack::Request.new(env)
|
@@ -46,7 +43,7 @@ class LinterServer
|
|
46
43
|
end
|
47
44
|
|
48
45
|
def self.start(port)
|
49
|
-
Rack::Handler::
|
46
|
+
Rack::Handler::WEBrick.run(LinterServer.new, :Port => port)
|
50
47
|
end
|
51
48
|
|
52
49
|
end
|
data/lib/settings.ini
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
[HardCodedCredentialsRule]
|
2
|
-
HardCodedCredentialsRule-enable_configuration =
|
2
|
+
HardCodedCredentialsRule-enable_configuration = false
|
3
3
|
HardCodedCredentialsRule-list_of_known_words_not_considered_in_credentials = pe-puppet,pe-webserver,pe-puppetdb,pe-postgres,pe-console-services,pe-orchestration-services,pe-ace-server,pe-bolt-server
|
4
4
|
HardCodedCredentialsRule-list_of_invalid_values_in_credentials = undefined,unset,www-data,wwwrun,www,no,yes,[],root
|
5
5
|
HardCodedCredentialsRule-regular_expression_of_words_present_in_credentials = (?-mix:user|usr|pass(word|_|$)|pwd|key|secret)
|
6
6
|
HardCodedCredentialsRule-regular_expression_of_words_not_present_in_credentials = (?-mix:gpg|path|type|buff|zone|mode|tag|header|scheme|length|guid)
|
7
7
|
|
8
8
|
[NoHTTPRule]
|
9
|
-
NoHTTPRule-enable_configuration =
|
9
|
+
NoHTTPRule-enable_configuration = false
|
10
10
|
NoHTTPRule-list_of_resources_that_can_use_http = apt::source,::apt::source,wget::fetch,yumrepo,yum::,aptly::mirror,util::system_package,yum::managed_yumrepo
|
11
11
|
NoHTTPRule-list_of_keywords_for_urls = backport,key,download,uri,mirror
|
12
12
|
NoHTTPRule-regular_expression_of_a_normal_http_address = (?-mix:^http:\/\/.+)
|
data/puppet-sec-lint.gemspec
CHANGED
@@ -30,13 +30,12 @@ Gem::Specification.new do |spec|
|
|
30
30
|
spec.require_paths = ["lib"]
|
31
31
|
|
32
32
|
# Uncomment to register a new dependency of your gem
|
33
|
-
spec.
|
34
|
-
spec.
|
35
|
-
spec.
|
36
|
-
spec.
|
37
|
-
spec.
|
38
|
-
spec.
|
39
|
-
spec.add_dependency 'launchy', '~> 2.5.0'
|
33
|
+
spec.add_runtime_dependency 'puppet-lint', '~> 2.4', '>= 2.4.2'
|
34
|
+
spec.add_runtime_dependency 'rake', '~> 13.0'
|
35
|
+
spec.add_runtime_dependency 'minitest', '~> 5.0'
|
36
|
+
spec.add_runtime_dependency 'rack', '~> 2.2.3'
|
37
|
+
spec.add_runtime_dependency 'inifile', '~> 3.0.0'
|
38
|
+
spec.add_runtime_dependency 'launchy', '~> 2.5.0'
|
40
39
|
|
41
40
|
# For more information and examples about making a new gem, checkout our
|
42
41
|
# guide at: https://bundler.io/guides/creating_gem.html
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: puppet-sec-lint
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tiago Ribeiro
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-05-
|
11
|
+
date: 2021-05-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: puppet-lint
|
@@ -72,20 +72,6 @@ dependencies:
|
|
72
72
|
- - "~>"
|
73
73
|
- !ruby/object:Gem::Version
|
74
74
|
version: 2.2.3
|
75
|
-
- !ruby/object:Gem::Dependency
|
76
|
-
name: thin
|
77
|
-
requirement: !ruby/object:Gem::Requirement
|
78
|
-
requirements:
|
79
|
-
- - "~>"
|
80
|
-
- !ruby/object:Gem::Version
|
81
|
-
version: 1.8.0
|
82
|
-
type: :runtime
|
83
|
-
prerelease: false
|
84
|
-
version_requirements: !ruby/object:Gem::Requirement
|
85
|
-
requirements:
|
86
|
-
- - "~>"
|
87
|
-
- !ruby/object:Gem::Version
|
88
|
-
version: 1.8.0
|
89
75
|
- !ruby/object:Gem::Dependency
|
90
76
|
name: inifile
|
91
77
|
requirement: !ruby/object:Gem::Requirement
|
@@ -149,14 +135,20 @@ files:
|
|
149
135
|
- docs/_posts/2021-05-03-welcome-to-jekyll.markdown
|
150
136
|
- docs/_site/404.html
|
151
137
|
- docs/_site/feed.xml
|
138
|
+
- docs/_site/images/puppet-sec-lint_console.png
|
139
|
+
- docs/_site/images/puppet-sec-lint_vscode.png
|
152
140
|
- docs/_site/index.html
|
153
141
|
- docs/_site/jekyll/update/2021/05/03/welcome-to-jekyll.html
|
142
|
+
- docs/admin-by-default.md
|
143
|
+
- docs/cyrillic-homograph-attack.md
|
144
|
+
- docs/empty-password.md
|
154
145
|
- docs/hard-coded-credentials.md
|
155
146
|
- docs/images/puppet-sec-lint_console.png
|
156
147
|
- docs/images/puppet-sec-lint_vscode.png
|
157
148
|
- docs/index.md
|
149
|
+
- docs/invalid-ip-addr-binding.md
|
150
|
+
- docs/weak-crypto-algorithm.md
|
158
151
|
- exe/puppet-sec-lint
|
159
|
-
- file.pp
|
160
152
|
- lib/configurations/boolean_configuration.rb
|
161
153
|
- lib/configurations/configuration.rb
|
162
154
|
- lib/configurations/list_configuration.rb
|
@@ -180,10 +172,6 @@ files:
|
|
180
172
|
- lib/settings.ini
|
181
173
|
- lib/sin/sin.rb
|
182
174
|
- lib/sin/sin_type.rb
|
183
|
-
- lib/test.txt
|
184
|
-
- lib/test2.rb
|
185
|
-
- lib/test3.rb
|
186
|
-
- lib/test_new.rb
|
187
175
|
- lib/visitors/configuration_visitor.rb
|
188
176
|
- puppet-sec-lint.gemspec
|
189
177
|
homepage: https://github.com/TiagoR98/puppet-sec-lint
|
data/file.pp
DELETED
@@ -1,77 +0,0 @@
|
|
1
|
-
# the following code addresses the bug: https://bugs.launchpad.net/keystone/+bug/1472285 .
|
2
|
-
|
3
|
-
class consul_template::service (
|
4
|
-
$pass = lols(3),
|
5
|
-
$aijoijooiumihhn_password = 'pe-puppet'
|
6
|
-
$admin = 'ceisssesrelometer',
|
7
|
-
$aijoijooiumihhn_password = '(adiyu(guygmin',
|
8
|
-
) {
|
9
|
-
exec { 'network-restart':
|
10
|
-
command => 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDM release-runner key',
|
11
|
-
path => '/usr/bin:/usr/sbin:/bin:/sbin',
|
12
|
-
refreshonly => true,
|
13
|
-
vmware_md5 => 'LOL',
|
14
|
-
autho => 'MDi09i09i5',
|
15
|
-
cmd => 'virsh secret-define --file ${secret_xml} && virsh secret-set-value --secret ${rbd_secret_uuid} --base64 $(ceph auth get-key client.${user})',
|
16
|
-
$auth_uri => 'http://127.0.0.1:5000',
|
17
|
-
address => '0.0.0.0',
|
18
|
-
user = 'admin',
|
19
|
-
password => '',
|
20
|
-
}
|
21
|
-
case $::osfamily {
|
22
|
-
'RedHat': {
|
23
|
-
exec { 'upload-img':
|
24
|
-
command => "/usr/bin/glance -N ${os_auth_url} -T ${os_tenant_name} -I ${os_username} -K ${os_password} add name=${img_name} is_public=${public} container_format=${container_format} disk_format=${disk_format} distro=${os_name} < /opt/vm/cirros-x86_64-disk.img",
|
25
|
-
unless => "/usr/bin/glance -N ${os_auth_url} -T ${os_tenant_name} -I ${os_username} -K ${os_password} index && (/usr/bin/glance -N ${os_auth_url} -T ${os_tenant_name} -I ${os_username} -K ${os_password} index | grep ${img_name})",
|
26
|
-
|
27
|
-
}
|
28
|
-
}
|
29
|
-
'Debian': {
|
30
|
-
exec { 'upload-img':
|
31
|
-
command => "/usr/bin/glance -N ${os_auth_url} -T ${os_tenant_name} -I ${os_username} -K ${os_password} add name=${img_name} is_public=${public} container_format=${container_format} disk_format=${disk_format} distro=${os_name} < /usr/share/cirros-testvm/cirros-x86_64-disk.img",
|
32
|
-
unless => "/usr/bin/glance -N ${os_auth_url} -T ${os_tenant_name} -I ${os_username} -K ${os_password} index && (/usr/bin/glance -N ${os_auth_url} -T ${os_tenant_name} -I ${os_username} -K ${os_password} index | grep ${img_name})",
|
33
|
-
key => "E8CC67053ED3B199",
|
34
|
-
key_content => '-----BEGIN PGP PUBLIC KEY BLOCK-----
|
35
|
-
Version: GnuPG v1.4.11 (GNU/Linux)
|
36
|
-
|
37
|
-
mQENBE/oXVkBCACcjAcV7lRGskECEHovgZ6a2robpBroQBW+tJds7B+qn/DslOAN
|
38
|
-
1hm0UuGQsi8pNzHDE29FMO3yOhmkenDd1V/T6tHNXqhHvf55nL6anlzwMmq3syIS
|
39
|
-
uqVjeMMXbZ4d+Rh0K/rI4TyRbUiI2DDLP+6wYeh1pTPwrleHm5FXBMDbU/OZ5vKZ
|
40
|
-
67j99GaARYxHp8W/be8KRSoV9wU1WXr4+GA6K7ENe2A8PT+jH79Sr4kF4uKC3VxD
|
41
|
-
BF5Z0yaLqr+1V2pHU3AfmybOCmoPYviOqpwj3FQ2PhtObLs+hq7zCviDTX2IxHBb
|
42
|
-
Q3mGsD8wS9uyZcHN77maAzZlL5G794DEr1NLABEBAAG0NU9wZW5TdGFja0BDaXNj
|
43
|
-
byBBUFQgcmVwbyA8b3BlbnN0YWNrLWJ1aWxkZEBjaXNjby5jb20+iQE4BBMBAgAi
|
44
|
-
BQJP6F1ZAhsDBgsJCAcDAgYVCAIJCgsEFgIDAQIeAQIXgAAKCRDozGcFPtOxmXcK
|
45
|
-
B/9WvQrBwxmIMV2M+VMBhQqtipvJeDX2Uv34Ytpsg2jldl0TS8XheGlUNZ5djxDy
|
46
|
-
u3X0hKwRLeOppV09GVO3wGizNCV1EJjqQbCMkq6VSJjD1B/6Tg+3M/XmNaKHK3Op
|
47
|
-
zSi+35OQ6xXc38DUOrigaCZUU40nGQeYUMRYzI+d3pPlNd0+nLndrE4rNNFB91dM
|
48
|
-
BTeoyQMWd6tpTwz5MAi+I11tCIQAPCSG1qR52R3bog/0PlJzilxjkdShl1Cj0RmX
|
49
|
-
7bHIMD66uC1FKCpbRaiPR8XmTPLv29ZTk1ABBzoynZyFDfliRwQi6TS20TuEj+ZH
|
50
|
-
xq/T6MM6+rpdBVz62ek6/KBcuQENBE/oXVkBCACgzyyGvvHLx7g/Rpys1WdevYMH
|
51
|
-
THBS24RMaDHqg7H7xe0fFzmiblWjV8V4Yy+heLLV5nTYBQLS43MFvFbnFvB3ygDI
|
52
|
-
IdVjLVDXcPfcp+Np2PE8cJuDEE4seGU26UoJ2pPK/IHbnmGWYwXJBbik9YepD61c
|
53
|
-
NJ5XMzMYI5z9/YNupeJoy8/8uxdxI/B66PL9QN8wKBk5js2OX8TtEjmEZSrZrIuM
|
54
|
-
rVVXRU/1m732lhIyVVws4StRkpG+D15Dp98yDGjbCRREzZPeKHpvO/Uhn23hVyHe
|
55
|
-
PIc+bu1mXMQ+N/3UjXtfUg27hmmgBDAjxUeSb1moFpeqLys2AAY+yXiHDv57ABEB
|
56
|
-
AAGJAR8EGAECAAkFAk/oXVkCGwwACgkQ6MxnBT7TsZng+AgAnFogD90f3ByTVlNp
|
57
|
-
Sb+HHd/cPqZ83RB9XUxRRnkIQmOozUjw8nq8I8eTT4t0Sa8G9q1fl14tXIJ9szzz
|
58
|
-
BUIYyda/RYZszL9rHhucSfFIkpnp7ddfE9NDlnZUvavnnyRsWpIZa6hJq8hQEp92
|
59
|
-
IQBF6R7wOws0A0oUmME25Rzam9qVbywOh9ZQvzYPpFaEmmjpCRDxJLB1DYu8lnC4
|
60
|
-
h1jP1GXFUIQDbcznrR2MQDy5fNt678HcIqMwVp2CJz/2jrZlbSKfMckdpbiWNns/
|
61
|
-
xKyLYs5m34d4a0it6wsMem3YCefSYBjyLGSd/kCI/CgOdGN1ZY1HSdLmmjiDkQPQ
|
62
|
-
UcXHbA==
|
63
|
-
=v6jg
|
64
|
-
-----END PGP PUBLIC KEY BLOCK-----',
|
65
|
-
|
66
|
-
}
|
67
|
-
}
|
68
|
-
}
|
69
|
-
file { '/var/lib/gerrit/.ssh/id_rsa' :
|
70
|
-
owner => 'gerrit',
|
71
|
-
group => 'gerrit',
|
72
|
-
mode => '0600',
|
73
|
-
content => $ssh_replication_rsa_key_contents,
|
74
|
-
replace => true,
|
75
|
-
require => File['/var/lib/gerrit/.ssh']
|
76
|
-
}
|
77
|
-
}
|
data/lib/test.txt
DELETED
data/lib/test2.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
require 'rjr/nodes/ws'
|
2
|
-
|
3
|
-
# listen for methods via amqp, websockets, http, and via local calls
|
4
|
-
|
5
|
-
ws_node = RJR::Nodes::WS.new :node_id => 'server', :host => '127.0.0.1', :port => 5007
|
6
|
-
|
7
|
-
|
8
|
-
# define a rpc method called 'hello' which takes
|
9
|
-
# one argument and returns it in upper case
|
10
|
-
ws_node.dispatcher.handle("initialize") { |processId,clientInfo,locale,rootPath,rootUri,capabilities,trace,workspaceFolders|
|
11
|
-
arg.upcase
|
12
|
-
}
|
13
|
-
|
14
|
-
# start the server and block
|
15
|
-
ws_node.listen
|
16
|
-
ws_node.join
|
data/lib/test3.rb
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
require 'socket' # Get sockets from stdlib
|
2
|
-
require 'json'
|
3
|
-
|
4
|
-
server = TCPServer.open(5007) # Socket to listen on port 2000
|
5
|
-
|
6
|
-
loop {
|
7
|
-
Thread.fork(server.accept) do |client|
|
8
|
-
while line=client.gets
|
9
|
-
length=Integer(line.scan(/\d/).join(''))
|
10
|
-
line=client.read(length+2)
|
11
|
-
request = JSON.parse(line)
|
12
|
-
puts line
|
13
|
-
|
14
|
-
response = {
|
15
|
-
jsonrpc: request['jsonrpc'],
|
16
|
-
result: {
|
17
|
-
capabilities: {
|
18
|
-
textDocumentSync:1
|
19
|
-
}
|
20
|
-
},
|
21
|
-
id: request['id']
|
22
|
-
}
|
23
|
-
|
24
|
-
response = JSON.generate(response)
|
25
|
-
|
26
|
-
client.flush
|
27
|
-
client.puts("Content-Length: "+response.length.to_s+"\r\n\r\n")
|
28
|
-
client.puts(response)
|
29
|
-
end
|
30
|
-
client.close
|
31
|
-
end
|
32
|
-
}
|
data/lib/test_new.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
require 'jimson'
|
2
|
-
|
3
|
-
class MyHandler
|
4
|
-
extend Jimson::Handler
|
5
|
-
|
6
|
-
def initi(a,b)
|
7
|
-
a + b
|
8
|
-
end
|
9
|
-
|
10
|
-
def initialize
|
11
|
-
super
|
12
|
-
end
|
13
|
-
|
14
|
-
end
|
15
|
-
|
16
|
-
server = Jimson::Server.new(MyHandler.new)
|
17
|
-
server.port = 5007
|
18
|
-
server.host = '127.0.0.1'
|
19
|
-
server.start # serve with webrick on http://0.0.0.0:8999/
|