Merge pull request #267555 from h7x4/pkgs-refactor-wordlists

authored by

Janik and committed by
GitHub
de20681f 8b7e94d3

+30 -27
+30 -27
pkgs/by-name/wo/wordlists/package.nix
··· 1 1 { lib 2 - , callPackage 2 + , symlinkJoin 3 3 , nmap 4 4 , rockyou 5 - , runtimeShell 6 5 , seclists 7 - , symlinkJoin 8 - , tree 9 6 , wfuzz 10 7 , lists ? [ 11 8 nmap ··· 13 10 seclists 14 11 wfuzz 15 12 ] 13 + , writeShellScriptBin 14 + , tree 16 15 }: 16 + let 17 + wordlistsCollection = symlinkJoin { 18 + name = "wordlists-collection"; 19 + paths = lists; 17 20 18 - symlinkJoin rec { 19 - pname = "wordlists"; 20 - version = "unstable-2023-10-10"; 21 + postBuild = '' 22 + shopt -s extglob 23 + rm -rf $out/!(share) 24 + rm -rf $out/share/!(wordlists) 25 + shopt -u extglob 26 + ''; 27 + }; 21 28 22 - name = "${pname}-${version}"; 23 - paths = lists; 29 + # A command to show the location of the links. 30 + wordlistsBin = writeShellScriptBin "wordlists" '' 31 + ${lib.getExe tree} ${wordlistsCollection}/share/wordlists 32 + ''; 33 + # A command for easy access to the wordlists. 34 + wordlistsPathBin = writeShellScriptBin "wordlists_path" '' 35 + printf "${wordlistsCollection}/share/wordlists\n" 36 + ''; 24 37 25 - postBuild = '' 26 - mkdir -p $out/bin 27 - 28 - # Create a command to show the location of the links. 29 - cat >> $out/bin/wordlists << __EOF__ 30 - #!${runtimeShell} 31 - ${tree}/bin/tree ${placeholder "out"}/share/wordlists 32 - __EOF__ 33 - chmod +x $out/bin/wordlists 38 + in symlinkJoin { 39 + name = "wordlists"; 34 40 35 - # Create a handy command for easy access to the wordlists. 36 - # e.g.: `cat "$(wordlists_path)/rockyou.txt"`, or `ls "$(wordlists_path)/dirbuster"` 37 - cat >> $out/bin/wordlists_path << __EOF__ 38 - #!${runtimeShell} 39 - printf "${placeholder "out"}/share/wordlists\n" 40 - __EOF__ 41 - chmod +x $out/bin/wordlists_path 42 - ''; 41 + paths = [ 42 + wordlistsCollection 43 + wordlistsBin 44 + wordlistsPathBin 45 + ]; 43 46 44 47 meta = with lib; { 45 48 description = "A collection of wordlists useful for security testing"; ··· 65 68 If you want to add a new package that provides wordlist/s the convention 66 69 is to copy it to {file}`$out/share/wordlists/myNewWordlist`. 67 70 ''; 68 - maintainers = with maintainers; [ janik pamplemousse ]; 71 + maintainers = with maintainers; [ janik pamplemousse h7x4 ]; 69 72 }; 70 73 }