Skip to content

Commit 40a7f0b

Browse files
committed
Fixed broken feature references
1 parent 50c889d commit 40a7f0b

6 files changed

Lines changed: 20 additions & 23 deletions

File tree

Resources/lib-mappings/java-se.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -214,12 +214,12 @@
214214
},
215215
{
216216
"namespace": "KeyStore",
217-
"categories": ["KeyStorage"],
217+
"categories": ["Key_Storage"],
218218
"children": []
219219
},
220220
{
221221
"namespace": "KeyStoreSpi",
222-
"categories": ["KeyStorage"],
222+
"categories": ["Key_Storage"],
223223
"children": []
224224
},
225225
{
@@ -244,12 +244,12 @@
244244
},
245245
{
246246
"namespace": "SecureRandom",
247-
"categories": ["SourceOfRandomness"],
247+
"categories": ["Source_of_Randomness"],
248248
"children": []
249249
},
250250
{
251251
"namespace": "SecureRandomSpi",
252-
"categories": ["SourceOfRandomness"],
252+
"categories": ["Source_of_Randomness"],
253253
"children": []
254254
},
255255
{
@@ -326,17 +326,17 @@
326326
},
327327
{
328328
"namespace": "EncryptedPrivateKeyInfo",
329-
"categories": ["KeyManagement"],
329+
"categories": ["Key_Management"],
330330
"children": []
331331
},
332332
{
333333
"namespace": "ExemptionMechanism",
334-
"categories": ["KeyManagement"],
334+
"categories": ["Key_Management"],
335335
"children": []
336336
},
337337
{
338338
"namespace": "ExemptionMechanismSpi",
339-
"categories": ["KeyManagement"],
339+
"categories": ["Key_Management"],
340340
"children": []
341341
},
342342
{

Resources/lib-mappings/java-servlet.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010
"children": [
1111
{
1212
"namespace": "HttpSession",
13-
"categories": ["SessionManagement"],
13+
"categories": ["Session_Management"],
1414
"children": []
1515
},
1616
{
1717
"namespace": "HttpServletRequest",
18-
"categories": ["SessionManagement"],
18+
"categories": ["Session_Management"],
1919
"children": []
2020
}
2121
]

Resources/lib-mappings/java-standard-library.json

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
"children": [
77
{
88
"namespace": "URLEncoder",
9-
"categories": ["DataSanitization"],
9+
"categories": ["Data_Sanitization"],
1010
"children": []
1111
},
1212
{
1313
"namespace": "URLDecoder",
14-
"categories": ["DataSanitization"],
14+
"categories": ["Data_Sanitization"],
1515
"children": []
1616
}
1717
],
@@ -28,7 +28,7 @@
2828
"children": [
2929
{
3030
"namespace": "ReentrantLock",
31-
"categories": ["StateSynchronization"],
31+
"categories": ["State_Synchronization"],
3232
"children": []
3333
}
3434
]
@@ -39,11 +39,6 @@
3939
"namespace": "Base64",
4040
"categories": ["Steganography"],
4141
"children": []
42-
},
43-
{
44-
"namespace": "Objects",
45-
"categories": ["Hashing"],
46-
"children": []
4742
}
4843
]
4944
}

Resources/lib-mappings/javax-crypto.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"children": [
1111
{
1212
"namespace": "SecretKeySpec",
13-
"categories": ["KeyManagement"],
13+
"categories": ["Key_Management"],
1414
"children": []
1515
}
1616
]

SecurityKeywordsBasedSearchTool/SecFeatFinder/FeatureModel.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55

66
def add_to_fm(fm, taxonomy, feature_name, tag):
77
taxo_feature = taxonomy.dfs(feature_name)
8-
8+
if taxo_feature is None:
9+
print(f"Feature '{feature_name}' not found in taxonomy.")
10+
return None
911
feature = taxo_feature
1012
parents = [feature]
1113
while feature.parent is not None:

SecurityKeywordsBasedSearchTool/SecFeatFinder/main.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ def process_feature_annotations(features_file, repo_dir, flattened_keywords, tax
5757
tag = f"API_{feature_name}_{method_name}"
5858
line_annotations[line_index].add(tag)
5959
library_features.add(tag)
60-
add_to_fm(fm, taxonomy, feature_name, tag)
60+
if add_to_fm(fm, taxonomy, feature_name, tag) is None:
61+
print(f"Feature '{feature_name}' not found in taxonomy, skipped for now.")
6162

6263
# Apply annotations to lines
6364
for line_index, tags in line_annotations.items():
@@ -300,8 +301,7 @@ def print_top_keywords(keyword_counter, total_matches):
300301

301302
def main():
302303
repo_url = input("Enter the repository URL: ")
303-
keyword_file = "SecFeatFinder/git@github.com:apache/tomcat.gitSecList.json"
304-
features_file = "../Resources/features.json"
304+
keyword_file = "SecFeatFinder/SecList.json"
305305
taxonomy_file = "../Resources/taxonomy.feature_model"
306306

307307
taxonomy = read_feature_model(taxonomy_file)
@@ -325,7 +325,7 @@ def main():
325325
fm = Feature(taxonomy.name, None)
326326

327327
# Process library annotations first
328-
library_features = process_feature_annotations(features_file, project_dir, flattened_keywords, taxonomy, fm)
328+
library_features = process_feature_annotations(project_dir+"/result/features.json", project_dir, flattened_keywords, taxonomy, fm)
329329

330330
# Initialize the exclusion counter ONCE here
331331
hans_exclusion_counter = [0]

0 commit comments

Comments
 (0)