Skip to content

Commit

Permalink
More robust fuzz-object (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
kazet authored Aug 31, 2024
1 parent fa8a5b3 commit 5d47611
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
2 changes: 2 additions & 0 deletions docker_image/patch_wordpress.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ else
/var/www/html/wp-includes/option.php
sed -i '/^function delete_site_option(/a fwrite(STDERR, "__GARLIC_CALL__" . json_encode(array("what" => "delete_site_option", "data" => array("name" => $option))) . "__ENDGARLIC__\\n");' \
/var/www/html/wp-includes/option.php
sed -i '/^function do_shortcode(/a fwrite(STDERR, "__GARLIC_CALL__" . json_encode(array("what" => "do_shortcode", "data" => array("content" => $content))) . "__ENDGARLIC__\\n");' \
/var/www/html/wp-includes/shortcodes.php
sed -i '/^function wp_delete_post(/a fwrite(STDERR, "__GARLIC_CALL__" . json_encode(array("what" => "wp_delete_post", "data" => array("id" => $postid))) . "__ENDGARLIC__\\n");' \
/var/www/html/wp-includes/post.php
sed -i '/^function wp_insert_post(/a fwrite(STDERR, "__GARLIC_CALL__" . json_encode(array("what" => "wp_insert_post", "data" => $postarr)) . "__ENDGARLIC__\\n");' \
Expand Down
28 changes: 19 additions & 9 deletions fuzz_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,21 +78,31 @@ def fuzz_object(
from_file = False
if "active_installs" not in object_info_dict:
soup = bs4.BeautifulSoup(requests.get(f"https://wordpress.org/{object_type.value}s/{slug}/").content)
object_info_dict["active_installs"] = (
soup.select("p.active_installs > strong")[0]
.text.replace("+", "")
.replace(",", "")
.replace("millions", "million")
.replace(" million", "000000")
)
try:
object_info_dict["active_installs"] = (
soup.select("p.active_installs > strong")[0]
.text.replace("+", "")
.replace(",", "")
.replace("millions", "million")
.replace(" million", "000000")
)
except IndexError:
object_info_dict["active_installs"] = 0

if file_or_folder_to_fuzz == "OBJECT_ROOT":
file_or_folder_to_fuzz = f"/var/www/html/wp-content/{object_type.value}s/{slug}"

if version is None:
version = object_info_dict["version"]
if "version" in object_info_dict:
version = object_info_dict["version"]
else:
version = None
active_installs = object_info_dict["active_installs"]
description = object_info_dict["sections"]["description"]

try:
description = object_info_dict["sections"]["description"]
except KeyError:
description = ""

dependencies = get_dependencies(slug, description)

Expand Down

0 comments on commit 5d47611

Please sign in to comment.