Skip to content

Commit d6092d9

Browse files
magifd2claude
andcommitted
fix: skip config permission check on Windows/NTFS (#1)
NTFS does not support Unix permission bits; reported mode is always 0666 regardless of ACL settings. The check is now skipped on Windows. Added documentation for securing config files via NTFS ACLs as an alternative to chmod. Closes #1 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 8054012 commit d6092d9

4 files changed

Lines changed: 42 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [2.0.3] - 2026-03-31
9+
10+
### Fixed
11+
- Skip config file permission check on Windows/NTFS (always reports 0666 regardless of ACLs)
12+
- Document NTFS ACL-based alternative for securing config files on Windows
13+
814
## [2.0.2] - 2026-03-27
915

1016
### Added

README.ja.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,20 @@ token = "your-token"
6666

6767
**優先順位(高い順):** CLI フラグ → 環境変数 → 設定ファイル
6868

69+
### Windows: 設定ファイルのセキュリティ
70+
71+
Unix/macOS では、設定ファイルが他ユーザーから読み取り可能な場合に警告が表示されます(`chmod 600` を推奨)。Windows (NTFS) では、NTFS が Unix パーミッションビットをサポートしないため、このチェックは自動的にスキップされます。
72+
73+
**ただし、設定ファイルには認証情報が含まれる可能性があるため、保護は必要です。** Windows では NTFS ACL でアクセスを制限してください:
74+
75+
```powershell
76+
# PowerShell: 設定ファイルを現在のユーザーのみに制限
77+
$path = "$env:USERPROFILE\.config\splunk-cli\config.toml"
78+
icacls $path /inheritance:r /grant:r "${env:USERNAME}:(R,W)"
79+
```
80+
81+
または、設定ファイルに認証情報を保存せず、環境変数(`SPLUNK_TOKEN` 等)を使用する方法もあります。
82+
6983
| 環境変数 | 説明 |
7084
|---|---|
7185
| `SPLUNK_HOST` | Splunk サーバー URL(ポート含む) |

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,20 @@ token = "your-token"
6666

6767
**Priority order (highest first):** CLI flags → environment variables → config file
6868

69+
### Windows: Config File Security
70+
71+
On Unix/macOS, splunk-cli warns if the config file is readable by other users (`chmod 600` is expected). On Windows (NTFS), this check is automatically skipped because NTFS does not support Unix permission bits.
72+
73+
**However, the config file may contain credentials and should still be protected.** On Windows, restrict access using NTFS ACLs:
74+
75+
```powershell
76+
# PowerShell: restrict config file to current user only
77+
$path = "$env:USERPROFILE\.config\splunk-cli\config.toml"
78+
icacls $path /inheritance:r /grant:r "${env:USERNAME}:(R,W)"
79+
```
80+
81+
Alternatively, use environment variables (`SPLUNK_TOKEN`, etc.) instead of storing credentials in the config file.
82+
6983
| Environment variable | Description |
7084
|---|---|
7185
| `SPLUNK_HOST` | Splunk server URL (including port) |

internal/config/config.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"io"
66
"os"
77
"path/filepath"
8+
"runtime"
89
"strings"
910
"time"
1011

@@ -120,6 +121,13 @@ func ApplyEnvVars(cfg *Config) {
120121
}
121122

122123
func checkPermissions(path string, info os.FileInfo) {
124+
// NTFS does not support Unix permission bits; reported mode is always
125+
// 0666 regardless of ACL settings, making this check meaningless.
126+
// On Windows, users should restrict access via NTFS ACLs instead.
127+
// See README.md "Windows: Config File Security" for guidance.
128+
if runtime.GOOS == "windows" {
129+
return
130+
}
123131
if info.Mode().Perm()&0077 != 0 {
124132
_, _ = fmt.Fprintf(Stderr,
125133
"Warning: config file %s has permissions %#o; expected 0600.\n"+

0 commit comments

Comments
 (0)