星期日, 3月 03, 2024

如何使用podman volume掛載nfs分享

資料來源:Mount an NFS Share Using a Rootful Podman Volume (oracle.com)

在建立 volume 時,就可以指定 nfs 的資訊

sudo podman volume create --opt type=nfs --opt o=rw --opt device=10.0.0.150:/nfs-share nfsvol

在建立完成後,podman 會去掛載 nfs 分享,這部份可以使用 mount 查看到掛載到哪個資料夾。接下來 podman 就可以使用 -v 參數,去指定要使用剛剛建立的 volume ,容器啟動後,就可以使用了。

例如

sudo podman run -v nfsvol:/foo -it --rm oraclelinux:9 ls -al /foo

這就表示把建立好的 nfsvol ,掛載到容器裡面的 /foo ,應用程式就可以存取到了。

網站是用wordpress做的嗎?

最近在幫朋友找 wordpress 佈景主題,所以在找是不是有工具可以分析網站,取得資訊。

結果就找到這篇:How to Discover Which WordPress Theme a Site is Using – GreenGeeks

這篇文章介紹了四個方法,其中一個方法是借助 IsItWP 這個網站。這個網站除了可以偵測網站是否用 wordpress 做的之外,也可以分析裡面用到的 plugin 或是 theme,真的是很方便。

其他兩個網站分別是

使用方法都很簡單,貼上要分析的網址就可以了。

最後一個萬不得已的方法就是看網頁原始碼了。

星期日, 2月 18, 2024

用trivy掃描KBOM

KBOM = Kubernetes Bills Of Material,就是 Kubernetes 的物料清單。

trivy 是由 Aqua Security 所開發的一個掃描工具,現在支援了 KBOM,可以依據 Kubernetes 務料清單裡的軟體來進行掃描,並產出報告。

安裝可以從 https://github.com/aquasecurity/trivy 來下載安裝,有提供以下方式

  • Container image
  • Debian package
  • RPM package
  • Homebrew

安裝好以後,就可以使用了。

那要掃描 KBOM ,要先產出 kbom.json,用以下指令就可以產出。這邊要注意,執行 trivy 的電腦上必須已經放置 ~/.kube/config ,這樣 trivy 才能存取到 k8s cluster。

trivy k8s cluster --format cyclonedx --output kbom.json

有了 kbom.json 以後,就可以用以下指令產出報告

trivy sbom kbom.json

我的 k8s 報告如下

2024-02-18T15:29:26.693+0800	INFO	Vulnerability scanning is enabled
2024-02-18T15:29:26.694+0800	INFO	Detected SBOM format: cyclonedx-json
2024-02-18T15:29:26.720+0800	WARN	No OS package is detected. Make sure you haven't deleted any files that contain information about the installed packages.
2024-02-18T15:29:26.721+0800	WARN	e.g. files under "/lib/apk/db/", "/var/lib/dpkg/" and "/var/lib/rpm"
2024-02-18T15:29:26.721+0800	INFO	Detected OS: ubuntu
2024-02-18T15:29:26.721+0800	WARN	This OS version is not on the EOL list: ubuntu 22.04.3
2024-02-18T15:29:26.721+0800	INFO	Detecting Ubuntu vulnerabilities...
2024-02-18T15:29:26.721+0800	INFO	Number of language-specific files: 3
2024-02-18T15:29:26.722+0800	INFO	Detecting kubernetes vulnerabilities...
2024-02-18T15:29:26.728+0800	INFO	Detecting gobinary vulnerabilities...

kbom.json (ubuntu 22.04.3)

Total: 0 (UNKNOWN: 0, LOW: 0, MEDIUM: 0, HIGH: 0, CRITICAL: 0)


 (gobinary)

Total: 3 (UNKNOWN: 0, LOW: 0, MEDIUM: 3, HIGH: 0, CRITICAL: 0)

┌──────────────────────────────────┬─────────────────────┬──────────┬────────┬───────────────────┬────────────────┬──────────────────────────────────────────────────────────┐
│             Library              │    Vulnerability    │ Severity │ Status │ Installed Version │ Fixed Version  │                          Title                           │
├──────────────────────────────────┼─────────────────────┼──────────┼────────┼───────────────────┼────────────────┼──────────────────────────────────────────────────────────┤
│ github.com/containerd/containerd │ CVE-2023-25153      │ MEDIUM   │ fixed  │ 1.6.15            │ 1.5.18, 1.6.18 │ containerd: OCI image importer memory exhaustion         │
│                                  │                     │          │        │                   │                │ https://avd.aquasec.com/nvd/cve-2023-25153               │
│                                  ├─────────────────────┤          │        │                   │                ├──────────────────────────────────────────────────────────┤
│                                  │ CVE-2023-25173      │          │        │                   │                │ containerd: Supplementary groups are not set up properly │
│                                  │                     │          │        │                   │                │ https://avd.aquasec.com/nvd/cve-2023-25173               │
│                                  ├─────────────────────┤          │        │                   ├────────────────┼──────────────────────────────────────────────────────────┤
│                                  │ GHSA-7ww5-4wqc-m92c │          │        │                   │ 1.6.26, 1.7.11 │ containerd allows RAPL to be accessible to a container   │
│                                  │                     │          │        │                   │                │ https://github.com/advisories/GHSA-7ww5-4wqc-m92c        │
└──────────────────────────────────┴─────────────────────┴──────────┴────────┴───────────────────┴────────────────┴──────────────────────────────────────────────────────────┘

從報告可以看出軟體元件的版本跟漏洞報告。

如果不產出 kbom.json ,也可以用另外一個方式掃描

trivy k8s cluster --scanners vuln --report summary

不過這指令在我的 k8s cluster,會有問題,我猜想是我 k8s cluster 不夠力的關係,就先這樣吧。

trivy 也有 operator 可以安裝,有機會再來看看怎麼使用。

參考資料

星期三, 2月 14, 2024

sitespeed.io 取得網站效能

 

來源:https://www.sitespeed.io/

專案已經提供了用容器啟動的方式,所以蠻容易的

docker run --rm -v "$(pwd):/sitespeed.io" sitespeedio/sitespeed.io:32.2.0 https://www.sitespeed.io/

執行完成後,會在當前目錄產生 sitespeed-result 目錄,目錄裡就有你需要的效能報告。

有需要撰寫自訂腳本測試的,可以參考 https://www.sitespeed.io/documentation/sitespeed.io/scripting/

效能報告以網頁呈現,用瀏覽器就可以開啟。