-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into article/gcp-certification-devops
- Loading branch information
Showing
44 changed files
with
4,112 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
StylesPath = .github/vale/styles | ||
MinAlertLevel = suggestion | ||
|
||
Vocab = Base | ||
|
||
Packages = write-good | ||
|
||
[*.md] | ||
BasedOnStyles = Vale, write-good |
Empty file.
Empty file.
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,22 @@ | ||
name: reviewdog | ||
|
||
on: [pull_request] | ||
|
||
jobs: | ||
prose: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Install and run Vale | ||
uses: errata-ai/vale-action@reviewdog | ||
env: | ||
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} | ||
with: | ||
version: 2.29.0 | ||
vale_flags: --config=${{github.workspace}}/.github/vale/.vale.ini | ||
reporter: github-pr-check | ||
fail_on_error: true | ||
filter_mode: added | ||
files: all | ||
|
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,27 @@ | ||
--- | ||
layout: post | ||
comments: true | ||
title: Elasticsearch use cases in cybersecurity | ||
excerpt: Learn about the difference use cases for Elasticsearch in a cybersecurity context | ||
tags: [elasticsearch,cybersecurity] | ||
toc: true | ||
img_excerpt: | ||
--- | ||
|
||
<img alt=" five main stages in the vulnerability management cycle" src="https://www.crowdstrike.com/wp-content/uploads/2020/05/vulnerability-management-cycle-1024x529.png"> | ||
<br/> | ||
|
||
|
||
- Data centralization: Elasticsearch provides a centralized repository for storing vulnerability data from disparate sources like threat intelligence feeds, asset inventory lists, application and system audits, and penetration testing reports. By consolidating this data, security operations teams can obtain an overarching view of their organization's vulnerabilities and prioritize remediation efforts accordingly. | ||
- Automatic parsing: As soon as new vulnerabilities are discovered or updated, they must go through manual triage, which requires extensive human effort and often leads to delays. Elasticsearch can automatically parse vulnerability data streams from various sources (e.g., CVE, NVD, OSVDB, MITRE ATT&CK) to extract necessary contextual attributes. Then, it assigns scores or severity ratings based on predefined rules tailored to each organization's unique environment. | ||
- Enhanced visibility: Elasticsearch indexes vulnerability records, allowing users to perform full-text queries, faceted navigation, and sorting. This capability provides enhanced visibility into the types, origins, and impact levels of the identified vulnerabilities, empowering administrators to focus attention on problem areas more precisely. | ||
- Adaptive workflow orchestration: Integration with Elasticsearch enables orchestration tools like open-source OSBase, Demisto, and Phantom Cyber to dynamically adjust their workstreams based on the current state of known vulnerabilities. This adaptive approach ensures that security practitioners always tackle high-priority weaknesses first while minimizing resource wastage on already-resolved issues. | ||
- Personalized notifications: Leveraging machine learning algorithms, Elasticsearch can assist in generating personalized notification strategies b | ||
|
||
|
||
- https://github.com/DSecureMe/vmc | ||
- https://github.com/opencve/opencve | ||
|
||
|
||
## That's all folks | ||
I hope you enjoyed this article, feel free to leave a comment or reach out on twitter [@bachiirc](https://twitter.com/bachiirc). |
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,123 @@ | ||
--- | ||
layout: post | ||
comments: true | ||
title: Stackable Trait in Scala | ||
excerpt: How to implement the Stackable Trait pattern in Scala | ||
tags: [scala,design-pattern] | ||
toc: true | ||
img_excerpt: | ||
--- | ||
|
||
<img align="center" src="/assets/logos/scala-full-color.svg" width="200" /> | ||
<br/> | ||
|
||
I come across some old scala code that uses what turns out to be a very rare pattern in Scala called Stackable Trait. The only reference to this pattern I could find on the Internet was [this old article](https://www.artima.com/articles/scalas-stackable-trait-pattern). In this article, we will explore how it can be used with a toy example. | ||
|
||
## Pattern | ||
From a high level, this pattern aims to reduce the boilerplate code needed to combine multiple implmentations but: | ||
- letting us write those implementations in different `trait`s and | ||
- then combining their functinality by simply extenting all of those `trait`. | ||
|
||
It can be implemented like this: | ||
|
||
1. First, declare a base trait with the functionality we want to stack | ||
|
||
```scala | ||
trait T { | ||
def func(): Unit = () | ||
} | ||
``` | ||
|
||
1. Then create couple of implementation traits that does different things when `func()` will be called | ||
|
||
```scala | ||
trait T1 extends T { | ||
abstract override def func(): Unit = { | ||
super.func() | ||
// implementation here | ||
} | ||
} | ||
|
||
trait T2 extends T { | ||
abstract override def func(): Unit = { | ||
super.func() | ||
// implementation here | ||
} | ||
} | ||
// more implementations | ||
``` | ||
|
||
1. Finally, we can stack those implementation in a class like this | ||
|
||
```scala | ||
class T3 extends T with T1 with T2 | ||
// or class T4 extends T with T2 with T1 | ||
``` | ||
|
||
Now if we call `func()` on an instance of `T3` both implementation from `T1` and `T2` will be called in that order. | ||
|
||
> Note how the implementation functions uses **`abstract`** and that inside them we call the parent implementation with **`super.func()`**. This subtle details is actually what makes the pattern works, If we omit one of those details it will not work. | ||
## Example | ||
Let's create a concrete example to better understand how this pattern works. In this example, the interfaces will simply add numbers to a queue so we could tell the order they were called. | ||
|
||
First, we define the interfaces | ||
|
||
```scala | ||
trait T { | ||
val queue = scala.collection.mutable.Buffer[Int]() | ||
def inc(): Unit = () | ||
} | ||
|
||
trait T1 extends T { | ||
abstract override def inc(): Unit = { | ||
super.inc() | ||
queue += 1 | ||
} | ||
} | ||
|
||
trait T2 extends T { | ||
abstract override def inc(): Unit = { | ||
super.inc() | ||
queue += 2 | ||
} | ||
} | ||
``` | ||
|
||
Now, we create instances and call our stacked function couple times to see how it is behaving. | ||
|
||
1. using the implementation order `T1` then `T2` | ||
|
||
```scala | ||
class T3 extends T with T1 with T2 | ||
|
||
val t = new T3() | ||
// t.queue shouldBe Seq() | ||
t.inc() | ||
// t.queue shouldBe Seq(1, 2) | ||
t.inc() | ||
// t.queue shouldBe Seq(1, 2, 1, 2) | ||
``` | ||
|
||
> Note how in this case the implementation of `T1` is called before the implementation of `T2` | ||
1. using the implementation order `T2` then `T1` | ||
|
||
```scala | ||
class T4 extends T with T2 with T1 | ||
|
||
val t = new T4() | ||
// t.queue shouldBe Seq() | ||
t.inc() | ||
// t.queue shouldBe Seq(2, 1) | ||
t.inc() | ||
// t.queue shouldBe Seq(2, 1, 2, 1) | ||
``` | ||
|
||
> Note how in this case the implementation of `T2` is called before the implementation of `T1`. | ||
|
||
## That's all folks | ||
The Stackable trait is an interesting pattern and enables us to write cleaner code by omitting the need to write explicit code to combine multiple implementations. Hopefully from now on you can use it or when you come across it in a code you're revewing you will be able to recognize it. | ||
|
||
I hope you enjoyed this article, feel free to leave a comment or reach out on twitter [@bachiirc](https://twitter.com/bachiirc). |
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,117 @@ | ||
--- | ||
layout: post | ||
comments: true | ||
title: Kibana startup fails with re2.node not valid for use in process library load disallowed by system policy | ||
excerpt: How to fix Kibana startup issue caused by re2.node not valid for use in process library load disallowed by system policy | ||
tags: [kibana,macos] | ||
toc: true | ||
img_excerpt: | ||
--- | ||
|
||
<img align="center" src="/assets/logos/kibana.svg" width="100" /> | ||
<br/> | ||
|
||
|
||
I was trying to setup Kibana locally on macOS Monterey version 12.5.1 (21G83), so I downloaded [Kibana](https://www.elastic.co/downloads/kibana) and installed it like this: | ||
|
||
```shell | ||
$ tar xzf kibana-8.5.3-darwin-aarch64.tar.gz | ||
$ cd cd kibana-8.5.3 | ||
``` | ||
|
||
But when I tried to start Kibana, I encountered the following error: | ||
|
||
```shell | ||
$ bin/kibana | ||
[2022-12-21T11:54:31.067+01:00][INFO ][node] Kibana process configured with roles: [background_tasks, ui] | ||
[2022-12-21T11:54:35.134+01:00][FATAL][root] Error: dlopen(/Users/dzlab/Tools/kibana-8.5.3/node_modules/re2/build/Release/re2.node, 0x0001): tried: '/Users/dzlab/Tools/kibana-8.5.3/node_modules/re2/build/Release/re2.node' (code signature in <1683A937-8902-34BD-9886-2F1CC674A96E> '/Users/dzlab/Tools/kibana-8.5.3/node_modules/re2/build/Release/re2.node' not valid for use in process: library load disallowed by system policy) | ||
at Object.Module._extensions..node (node:internal/modules/cjs/loader:1239:18) | ||
at Module.load (node:internal/modules/cjs/loader:1033:32) | ||
at Function.Module._load (node:internal/modules/cjs/loader:868:12) | ||
at Module.require (node:internal/modules/cjs/loader:1057:19) | ||
at Module.Hook._require.Module.require (/Users/dzlab/Tools/kibana-8.5.3/node_modules/require-in-the-middle/index.js:101:39) | ||
at Module.Hook._require.Module.require (/Users/dzlab/Tools/kibana-8.5.3/node_modules/require-in-the-middle/index.js:101:39) | ||
at Module.Hook._require.Module.require (/Users/dzlab/Tools/kibana-8.5.3/node_modules/require-in-the-middle/index.js:101:39) | ||
at Module.Hook._require.Module.require (/Users/dzlab/Tools/kibana-8.5.3/node_modules/require-in-the-middle/index.js:101:39) | ||
at Module.Hook._require.Module.require (/Users/dzlab/Tools/kibana-8.5.3/node_modules/require-in-the-middle/index.js:101:39) | ||
at Module.Hook._require.Module.require (/Users/dzlab/Tools/kibana-8.5.3/node_modules/require-in-the-middle/index.js:101:39) | ||
at require (node:internal/modules/cjs/helpers:103:18) | ||
at Object.<anonymous> (/Users/dzlab/Tools/kibana-8.5.3/node_modules/re2/re2.js:3:13) | ||
at Module._compile (node:internal/modules/cjs/loader:1155:14) | ||
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1209:10) | ||
at Module.load (node:internal/modules/cjs/loader:1033:32) | ||
at Function.Module._load (node:internal/modules/cjs/loader:868:12) | ||
at Module.require (node:internal/modules/cjs/loader:1057:19) | ||
at Module.Hook._require.Module.require (/Users/dzlab/Tools/kibana-8.5.3/node_modules/require-in-the-middle/index.js:101:39) | ||
at Module.Hook._require.Module.require (/Users/dzlab/Tools/kibana-8.5.3/node_modules/require-in-the-middle/index.js:101:39) | ||
at Module.Hook._require.Module.require (/Users/dzlab/Tools/kibana-8.5.3/node_modules/require-in-the-middle/index.js:101:39) | ||
at Module.Hook._require.Module.require (/Users/dzlab/Tools/kibana-8.5.3/node_modules/require-in-the-middle/index.js:101:39) | ||
at Module.Hook._require.Module.require (/Users/dzlab/Tools/kibana-8.5.3/node_modules/require-in-the-middle/index.js:101:39) | ||
at Module.Hook._require.Module.require (/Users/dzlab/Tools/kibana-8.5.3/node_modules/require-in-the-middle/index.js:101:39) | ||
at require (node:internal/modules/cjs/helpers:103:18) | ||
at Object.<anonymous> (/Users/dzlab/Tools/kibana-8.5.3/x-pack/plugins/ml/server/saved_objects/service.js:12:34) | ||
at Module._compile (node:internal/modules/cjs/loader:1155:14) | ||
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1209:10) | ||
at Module.load (node:internal/modules/cjs/loader:1033:32) | ||
at Function.Module._load (node:internal/modules/cjs/loader:868:12) | ||
at Module.require (node:internal/modules/cjs/loader:1057:19) | ||
at Module.Hook._require.Module.require (/Users/dzlab/Tools/kibana-8.5.3/node_modules/require-in-the-middle/index.js:101:39) | ||
at Module.Hook._require.Module.require (/Users/dzlab/Tools/kibana-8.5.3/node_modules/require-in-the-middle/index.js:101:39) | ||
at Module.Hook._require.Module.require (/Users/dzlab/Tools/kibana-8.5.3/node_modules/require-in-the-middle/index.js:101:39) | ||
at Module.Hook._require.Module.require (/Users/dzlab/Tools/kibana-8.5.3/node_modules/require-in-the-middle/index.js:101:39) | ||
at Module.Hook._require.Module.require (/Users/dzlab/Tools/kibana-8.5.3/node_modules/require-in-the-middle/index.js:101:39) | ||
at Module.Hook._require.Module.require (/Users/dzlab/Tools/kibana-8.5.3/node_modules/require-in-the-middle/index.js:101:39) | ||
at require (node:internal/modules/cjs/helpers:103:18) | ||
at Object.<anonymous> (/Users/dzlab/Tools/kibana-8.5.3/x-pack/plugins/ml/server/saved_objects/index.js:45:16) | ||
at Module._compile (node:internal/modules/cjs/loader:1155:14) | ||
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1209:10) | ||
at Module.load (node:internal/modules/cjs/loader:1033:32) | ||
at Function.Module._load (node:internal/modules/cjs/loader:868:12) | ||
at Module.require (node:internal/modules/cjs/loader:1057:19) | ||
at Module.Hook._require.Module.require (/Users/dzlab/Tools/kibana-8.5.3/node_modules/require-in-the-middle/index.js:101:39) | ||
at Module.Hook._require.Module.require (/Users/dzlab/Tools/kibana-8.5.3/node_modules/require-in-the-middle/index.js:101:39) | ||
at Module.Hook._require.Module.require (/Users/dzlab/Tools/kibana-8.5.3/node_modules/require-in-the-middle/index.js:101:39) | ||
at Module.Hook._require.Module.require (/Users/dzlab/Tools/kibana-8.5.3/node_modules/require-in-the-middle/index.js:101:39) | ||
at Module.Hook._require.Module.require (/Users/dzlab/Tools/kibana-8.5.3/node_modules/require-in-the-middle/index.js:101:39) | ||
at Module.Hook._require.Module.require (/Users/dzlab/Tools/kibana-8.5.3/node_modules/require-in-the-middle/index.js:101:39) | ||
at require (node:internal/modules/cjs/helpers:103:18) | ||
|
||
FATAL Error: dlopen(/Users/dzlab/Tools/kibana-8.5.3/node_modules/re2/build/Release/re2.node, 0x0001): tried: '/Users/dzlab/Tools/kibana-8.5.3/node_modules/re2/build/Release/re2.node' (code signature in <1683A937-8902-34BD-9886-2F1CC674A96E> '/Users/dzlab/Tools/kibana-8.5.3/node_modules/re2/build/Release/re2.node' not valid for use in process: library load disallowed by system policy) | ||
``` | ||
I tried to look up for resolutions and the only thing I could found was this [Kibana issue](https://github.com/elastic/kibana/issues/121864) which is closed with a suggestioon to instead install kibana version `7.16.2`. OK so I just need to download that version or try to understand the issue. | ||
In fact, this issue is cause by macOS having stricter signature checks for binaries, causing install issues for a lot of applications (for instance see [link](https://support.blackfire.io/en/articles/3669492-issues-with-macos-catalina)). | ||
In this case, the error basically means osx had put `node.re` in quarantine, we can confirm this using `codesign` and `xattr` as follows: | ||
```shell | ||
$ codesign -vvvv /Users/dzlab/Tools/kibana-8.5.3/node_modules/re2/build/Release/re2.node | ||
/Users/dzlab/Tools/kibana-8.5.3/node_modules/re2/build/Release/re2.node: valid on disk | ||
/Users/dzlab/Tools/kibana-8.5.3/node_modules/re2/build/Release/re2.node: satisfies its Designated Requirement | ||
$ xattr /Users/dzlab/Tools/kibana-8.5.3/node_modules/re2/build/Release/re2.node | ||
com.apple.quarantine | ||
``` | ||
Notice the attribute `com.apple.quarantine` which is added by macOS to any binary file that is considered suspicious. By default all software is suspicious according to macOS, especially if it is downlaoded form the internet and as a result it is put in quarantine by setting the `com.apple.quarantine` extended attribute. So one way to fix this is to remove this attribute with `xattr -d`: | ||
```shell | ||
$ xattr -d com.apple.quarantine /Users/dzlab/Tools/kibana-8.5.3/node_modules/re2/build/Release/re2.node | ||
$ xattr /Users/dzlab/Tools/kibana-8.5.3/node_modules/re2/build/Release/re2.node | ||
``` | ||
Notice how after removing the `com.apple.quarantine` attribute we don't see it anymore in the output of `xattr`. | ||
Now we can start Kibana which will be available at http://localhost:5601 | ||
```shell | ||
$ bin/kibana | ||
[2022-12-21T12:58:37.552+01:00][INFO ][node] Kibana process configured with roles: [background_tasks, ui] | ||
[2022-12-21T12:58:43.152+01:00][INFO ][plugins-service] Plugin "cloudExperiments" is disabled. | ||
Go to http://localhost:5601/?code=242129 to get started. | ||
``` | ||
## That's all folks | ||
I hope you enjoyed this article, feel free to leave a comment or reach out on twitter [@bachiirc](https://twitter.com/bachiirc). |
Oops, something went wrong.