Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add dynamic integer wordlist support #1995

Merged
merged 1 commit into from
Jan 17, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Random;
import java.util.Set;
import java.util.UUID;
import java.util.regex.Matcher;
Expand Down Expand Up @@ -473,6 +474,18 @@ public static Map<String, List<String>> resolveWordList(Map<String, List<String>
}
}

if (m.containsKey("count")) {
int count;
if (m.get("count") instanceof String) {
count = Integer.valueOf(m.get("count"));
} else {
count = Integer.valueOf((String.valueOf(m.get("count"))));
}
List<String> vals = generateUniqueTenDigitNumbers(count);
wordListsMap.put(k, vals);
continue;
}

keyObj = m.get("key");
location = m.get("location");
if (keyObj instanceof Map) {
Expand Down Expand Up @@ -524,6 +537,24 @@ public static Map<String, List<String>> resolveWordList(Map<String, List<String>

}

public static List<String> generateUniqueTenDigitNumbers(int count) {
if (count > 1_000_000_000) {
throw new IllegalArgumentException("Cannot generate more than 1 billion unique 10-digit numbers.");
}

List<String> uniqueNumbers = new ArrayList<>();
Random random = new Random();

while (uniqueNumbers.size() < count) {
// Generate a 10-digit number starting with 1
int number = 1_000_000_000 + random.nextInt(1_000_000_000); // Ensures the number starts with 1
uniqueNumbers.add(String.valueOf(number));
}

return uniqueNumbers;
}


public static Map<String, Object> resolveDynamicWordList(Map<String, Object> varMap, ApiInfo.ApiInfoKey apiInfoKey, Map<ApiInfo.ApiInfoKey, List<String>> newSampleDataMap) {

Map<String, Object> updatedVarMap = new HashMap<>();
Expand Down Expand Up @@ -623,6 +654,17 @@ public static void resolveWordList(Map<String, Object> varMap, Map<ApiInfoKey, L
continue;
}
}
if (m.containsKey("count")) {
int count;
if (m.get("count") instanceof String) {
count = Integer.valueOf(m.get("count"));
} else {
count = Integer.valueOf((String.valueOf(m.get("count"))));
}
List<String> vals = generateUniqueTenDigitNumbers(count);
varMap.put(k, vals);
continue;
}
keyObj = m.get("key");
if (keyObj instanceof Map) {
Map<String, String> kMap = (Map) keyObj;
Expand Down
Loading