1
1
package net .bytebutcher .burpsendtoextension .models ;
2
2
3
+ import com .google .common .collect .Lists ;
3
4
import com .google .common .collect .Sets ;
4
5
import net .bytebutcher .burpsendtoextension .models .placeholder .IPlaceholder ;
5
6
import net .bytebutcher .burpsendtoextension .utils .StringUtils ;
@@ -94,13 +95,21 @@ public int hashCode() {
94
95
return Objects .hash (id );
95
96
}
96
97
97
- public boolean isValid (List <Map <String , IPlaceholder >> placeholders ) {
98
+ public List <Map <String , IPlaceholder >> getValid (List <Map <String , IPlaceholder >> placeholders ) {
99
+ List <Map <String , IPlaceholder >> validItems = Lists .newArrayList ();
98
100
for (Map <String , IPlaceholder > placeholderMap : placeholders ) {
99
- for (String placeholder : getInternalPlaceHolders ()) {
100
- if (placeholderMap .containsKey (placeholder )) {
101
- if (!placeholderMap .get (placeholder ).isValid ()) {
102
- return false ;
103
- }
101
+ if (isValid (placeholderMap )) {
102
+ validItems .add (placeholderMap );
103
+ }
104
+ }
105
+ return validItems ;
106
+ }
107
+
108
+ private boolean isValid (Map <String , IPlaceholder > placeholderMap ) {
109
+ for (String placeholder : getInternalPlaceHolders ()) {
110
+ if (placeholderMap .containsKey (placeholder )) {
111
+ if (!placeholderMap .get (placeholder ).isValid ()) {
112
+ return false ;
104
113
}
105
114
}
106
115
}
@@ -115,7 +124,7 @@ public String getFormattedCommand(List<Map<String, IPlaceholder>> placeholderMap
115
124
try {
116
125
String originalCommand = getCommand ();
117
126
for (String internalPlaceHolder : getInternalPlaceHolders ()) {
118
- String value = placeholderMap .stream ().map (m -> m .get (internalPlaceHolder )).map (iPlaceholder -> iPlaceholder .getValue (internalPlaceHolder )).collect (Collectors .joining ("," ));
127
+ String value = getValid ( placeholderMap ) .stream ().map (m -> m .get (internalPlaceHolder )).map (iPlaceholder -> iPlaceholder .getValue (internalPlaceHolder )).collect (Collectors .joining ("," ));
119
128
boolean doesRequireShellEscape = placeholderMap .get (0 ).get (internalPlaceHolder ).doesRequireShellEscape ();
120
129
originalCommand = originalCommand .replace (internalPlaceHolder , doesRequireShellEscape ? "'" + StringUtils .shellEscape (value ) + "'" : value );
121
130
}
0 commit comments