prjblk / wordpress-audit-automation

Scripts to download every Wordpress plugin (updated in the last 2 years) and run Semgrep over the lot of it while storing output in a database.
47 stars 13 forks source link

Mysql issue #2

Open random-robbie opened 1 day ago

random-robbie commented 1 day ago

Hey,

I've tried mysql 5.7 and 8.0 and keep getting the following issue.

python3 wordpress-plugin-audit.py --create-schema --audit
Auditing plugins:   0%|                                                                                                                                                                                               | 0/104 [00:00<?, ?it/s]
┌──── ○○○ ────┐
│ Semgrep CLI │
└─────────────┘

Auditing plugins:   1%|█▊                                                                                                                                                                                     | 1/104 [00:05<09:35,  5.59s/it]
┌──── ○○○ ────┐
│ Semgrep CLI │
└─────────────┘

Auditing plugins:   2%|███▌                                                                                                                                                                                   | 2/104 [00:07<06:01,  3.55s/it]
┌──── ○○○ ────┐
│ Semgrep CLI │
└─────────────┘

Auditing plugins:   2%|███▌                                                                                                                                                                                   | 2/104 [00:10<09:16,  5.45s/it]
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/mysql/connector/connection_cext.py", line 555, in cmd_query
    self._cmysql.query(
_mysql_connector.MySQLInterfaceError: Cannot add or update a child row: a foreign key constraint fails (`wordpress`.`PluginResults`, CONSTRAINT `PluginResults_ibfk_1` FOREIGN KEY (`slug`) REFERENCES `PluginData` (`slug`))

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/rwiggins/tools/wordpress-audit-automation/wordpress-plugin-audit.py", line 199, in <module>
    run_semgrep_and_store_results(
  File "/Users/rwiggins/tools/wordpress-audit-automation/wordpress-plugin-audit.py", line 136, in run_semgrep_and_store_results
    insert_result_into_db(cursor, plugin, item)
  File "/Users/rwiggins/tools/wordpress-audit-automation/dbutils.py", line 136, in insert_result_into_db
    cursor.execute(sql, data)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/mysql/connector/cursor_cext.py", line 276, in execute
    result = self._cnx.cmd_query(
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/mysql/connector/connection_cext.py", line 563, in cmd_query
    raise get_mysql_exception(
mysql.connector.errors.IntegrityError: 1452 (23000): Cannot add or update a child row: a foreign key constraint fails (`wordpress`.`PluginResults`, CONSTRAINT `PluginResults_ibfk_1` FOREIGN KEY (`slug`) REFERENCES `PluginData` (`slug`))

any suggestions?

random-robbie commented 1 day ago

Closing as i might have an idea of what it is.

random-robbie commented 23 hours ago

Reopen - Still having issues with this from a fresh install. Tried using docker mysql:latest and 5.7 and just done a fresh vm of ubuntu 22.04 and got same issue.

random-robbie commented 2 hours ago

Just tried with importing your audit.sql and then trying to reaudit and it's done the same.