Skip to content

Commit 760f295

Browse files
author
Christian Förster
committed
removing unused setting and updating Readme
1 parent eb30e6c commit 760f295

5 files changed

Lines changed: 28 additions & 79 deletions

File tree

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,6 @@ go.work.sum
4444

4545
.DS_Store
4646

47-
*.html
47+
.claude
48+
49+
*.html

ReadMe.md

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ Currently only a few checks are implemented:
1010
- HasNoWhiteSpace (for filenames)
1111
- IsFreeOfKeywords (checking file contents); non binary, .xlsx and .docx are supported
1212
- IsValidName (checking if nonsense files are present eg: .Rhistory)
13+
- HasFileNameSpecialChars (~!?@#$%^&*`;,'"()<>[]{})
14+
- IsFileNameTooLong (>64 is too long)
1315

14-
Archives (.zip, .tar, .7z) are also supported. On these the content (IsFreeOfKeywords) on each file is **not** checked.
16+
Archives (.zip, .tar, .7z) are also supported. On these the content (IsFreeOfKeywords) on each file is checked if the file is not too big.
1517
As *.tar.gz* files require complete unpacking of the archive to access the list of contained files it is not supported as it would be too slow for large archives.
1618

1719
**By respository:**
@@ -87,6 +89,21 @@ or you compile first and run via:
8789
pc -location your-ckan-package-name
8890
```
8991

92+
run with Terminal User Interface:
93+
```bash
94+
pc -config pc.toml -location . --tui
95+
```
96+
97+
run with html output:
98+
```bash
99+
pc -config pc.toml -location . --html report.html
100+
```
101+
102+
run with plain output:
103+
```bash
104+
pc -config pc.toml -location . --plain
105+
```
106+
90107
## Building
91108
To build (https://github.com/confluentinc/confluent-kafka-go/issues/1092#issuecomment-2373681430):
92109
```bash
@@ -159,8 +176,3 @@ ssh -t user@remote-server "TERM=xterm-256color LANG=en_US.UTF-8 cd /path/to/pc &
159176
go test ./...
160177
```
161178

162-
## Next steps
163-
164-
I added to new checks in the checks by file file. Please include these in the config and add white and blacklist functionalities as requires. I believe it should already be implemented. Please hten add the corresponding sdections to the 3 toml files.
165-
166-
After adding the tests please check the functionality of pc. I belive there must be a bug. Running this go run . -config pc.toml -location testdata/archives should find a lot of problem but it is not. the data in the different archive formats is identical. So it should always find the same for zip, tar and 7z. What is going on?

pc.toml.example

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@
3939
#####################################################################################
4040

4141
[general]
42-
# Maximum number of messages of the same type before truncating
43-
maxMessagesPerType = 5
4442
# Maximum size for individual files in archives (bytes) - 10MB
4543
maxArchiveFileSize = 10485760
4644
# Maximum total memory for archive processing (bytes) - 500MB
@@ -70,13 +68,10 @@ whitelist = []
7068
keywordArguments = [
7169
{ keywords = ["password", "secret", "key", "token", "api", "credential", "auth"], info = "Security credentials detected" },
7270
{ keywords = ["id_rsa", "id_ed25519", "BEGIN PRIVATE KEY", "BEGIN RSA PRIVATE KEY"], info = "Private key detected" },
73-
{ keywords = ["AKIAI", "AKIA", "sk_live", "sk_test", "xoxb", "xoxp"], info = "API key detected" },
7471
{ keywords = ["jwt", "bearer", "oauth", "client_secret"], info = "Authentication token detected" },
7572
{ keywords = ["database", "db_password", "connection_string"], info = "Database credentials detected" },
76-
{ keywords = ["stripe", "paypal", "sendgrid", "twilio", "slack"], info = "Third-party service credentials" },
77-
{ keywords = ["/Users/", "C:\\Users\\", "Q:"], info = "Hardcoded file paths detected" },
78-
{ keywords = ["admin", "root", "superuser"], info = "Administrative accounts detected" },
79-
{ keywords = ["ssn", "social_security", "credit_card", "phone"], info = "PII detected" }
73+
{ keywords = ["/home/", "/Users/", "C:\\Users\\", "Q:"], info = "Hardcoded file paths detected" },
74+
{ keywords = ["admin", "root", "superuser"], info = "Administrative accounts detected" }
8075
]
8176

8277
[test.HasFileNameSpecialChars]
@@ -104,7 +99,7 @@ keywordArguments = [
10499
".Rbuildignore", "__pycache__", ".vscode",
105100
".ipynb_checkpoints", "venv", ".idea", ".egg-info",
106101
".pytest_cache", ".pyc", ".tox", ".python_version",
107-
".coverage", ".benchmark", ".doc", ".xls"
102+
".coverage", ".benchmark", ".doc", ".xls", ".DS_Store"
108103
]}
109104
]
110105

pkg/config/config_parser.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ type OperationConfig struct {
2323
}
2424

2525
type GeneralConfig struct {
26-
MaxMessagesPerType int
2726
MaxArchiveFileSize int64 // Maximum size for individual files in archives (bytes)
2827
MaxTotalArchiveMemory int64 // Maximum total memory for archive processing (bytes)
2928
MaxContentScanFileSize int64 // Maximum size for files that read content (like IsFreeOfKeywords) (bytes)
@@ -45,7 +44,6 @@ func ParseConfig(filename string) (*Config, error) {
4544

4645
c := &Config{
4746
General: &GeneralConfig{
48-
MaxMessagesPerType: 10, // Default value
4947
MaxArchiveFileSize: 10 * 1024 * 1024, // 10MB default
5048
MaxTotalArchiveMemory: 100 * 1024 * 1024, // 100MB default
5149
MaxContentScanFileSize: 1024 * 1024 * 1024, // 1GB default for content scanning
@@ -86,9 +84,6 @@ func ParseConfig(filename string) (*Config, error) {
8684

8785
// Parse general section
8886
if generalData, ok := raw["general"].(map[string]interface{}); ok {
89-
if maxMsgs, ok := generalData["maxMessagesPerType"].(int64); ok {
90-
c.General.MaxMessagesPerType = int(maxMsgs)
91-
}
9287
if maxArchiveFileSize, ok := generalData["maxArchiveFileSize"].(int64); ok {
9388
c.General.MaxArchiveFileSize = maxArchiveFileSize
9489
}

pkg/utils/archive_parallel_test.go

Lines changed: 4 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,16 @@ import (
77
"github.com/eawag-rdm/pc/pkg/structs"
88
)
99

10-
// TestArchiveParallelProcessing tests that all archives of the same type
10+
// TestArchiveParallelProcessing tests that all archives of the same type
1111
// (with different extensions) are processed and their messages are preserved.
1212
// This test ensures the message truncation bug doesn't regress.
1313
func TestArchiveParallelProcessing(t *testing.T) {
1414
// Create test configuration similar to production
1515
cfg := config.Config{
1616
General: &config.GeneralConfig{
17-
MaxMessagesPerType: 5,
18-
MaxArchiveFileSize: 10485760, // 10MB
19-
MaxTotalArchiveMemory: 536870912, // 500MB
20-
MaxContentScanFileSize: 20971520, // 20MB
17+
MaxArchiveFileSize: 10485760, // 10MB
18+
MaxTotalArchiveMemory: 536870912, // 500MB
19+
MaxContentScanFileSize: 20971520, // 20MB
2120
},
2221
Tests: map[string]*config.TestConfig{
2322
"IsFreeOfKeywords": {
@@ -81,57 +80,3 @@ func TestArchiveParallelProcessing(t *testing.T) {
8180
t.Errorf("Expected %d unique archives, found %d", expectedArchiveCount, len(archiveNames))
8281
}
8382
}
84-
85-
// TestArchiveProcessingWithoutTruncation verifies that disabling message truncation
86-
// preserves all archive messages, which was the root cause of the original bug.
87-
func TestArchiveProcessingWithoutTruncation(t *testing.T) {
88-
cfg := config.Config{
89-
General: &config.GeneralConfig{
90-
MaxMessagesPerType: 2, // Very low limit to trigger truncation if enabled
91-
},
92-
Tests: map[string]*config.TestConfig{
93-
"IsFreeOfKeywords": {
94-
KeywordArguments: []map[string]interface{}{
95-
{"keywords": []string{"test"}, "info": "Test keyword"},
96-
},
97-
},
98-
},
99-
}
100-
101-
// Create multiple archive files that would trigger truncation
102-
files := []structs.File{
103-
{Path: "archive1.zip", Name: "archive1.zip", IsArchive: true},
104-
{Path: "archive2.zip", Name: "archive2.zip", IsArchive: true},
105-
{Path: "archive3.zip", Name: "archive3.zip", IsArchive: true},
106-
{Path: "archive4.zip", Name: "archive4.zip", IsArchive: true},
107-
{Path: "archive5.zip", Name: "archive5.zip", IsArchive: true},
108-
}
109-
110-
// Mock check that returns archive-like messages (which would be grouped together)
111-
mockCheck := func(file structs.File, config config.Config) []structs.Message {
112-
return []structs.Message{
113-
{
114-
Content: "Test keyword 'test'. In archived file: 'test.txt'",
115-
Source: file,
116-
},
117-
}
118-
}
119-
120-
// Use ApplyChecksFilteredByFileOnArchive directly to test our specific function
121-
messages := ApplyChecksFilteredByFileOnArchive(cfg, []func(structs.File, config.Config) []structs.Message{mockCheck}, files)
122-
123-
// All 5 messages should be preserved (no truncation)
124-
if len(messages) != 5 {
125-
t.Errorf("Expected 5 messages without truncation, got %d", len(messages))
126-
}
127-
128-
// Verify all archives are represented
129-
uniqueArchives := make(map[string]bool)
130-
for _, msg := range messages {
131-
uniqueArchives[msg.Source.(structs.File).Name] = true
132-
}
133-
134-
if len(uniqueArchives) != 5 {
135-
t.Errorf("Expected messages from 5 different archives, got %d", len(uniqueArchives))
136-
}
137-
}

0 commit comments

Comments
 (0)