diff --git a/content/posts/2021-07.md b/content/posts/2021-07.md
index 8d09d68de..ba9d4bbcc 100644
--- a/content/posts/2021-07.md
+++ b/content/posts/2021-07.md
@@ -431,4 +431,20 @@ $ cat roles/dspace/templates/nginx/abusive-networks.conf.j2 /tmp/abusive-network
- I deployed the block list on CGSpace (linode18) and the load is down to 1.0 but I see there are still some DDoS IPs getting through... sigh
- The next thing I need to do is purge all the IPs from Solr using grepcidr...
+## 2021-07-18
+
+- After blocking all the ASN network blocks yesterday I still see requests getting through from these abusive networks, so the ASN lists must be out of date
+ - I decided to get a lit of all the IPs that made requests on the server in the last two days, resolve them, and then filter out those from these ASNs: 206485, 35624, 36352, 46844, 49453, 62282
+
+```console
+$ sudo zcat --force /var/log/nginx/access.log /var/log/nginx/access.log.1 /var/log/nginx/access.log.2 | grep -E " (200|499) " | awk '{print $1}' | sort | uniq > /tmp/all-ips.txt
+$ ./ilri/resolve-addresses-geoip2.py -i /tmp/all-ips.txt -o /tmp/all-ips-out.csv
+$ csvgrep -c asn -r '^(206485|35624|36352|46844|49453|62282)$' /tmp/all-ips-out.csv | csvcut -c ip | sed 1d | sort | uniq > /tmp/all-ips-to-block.txt
+$ wc -l /tmp/all-ips-to-block.txt
+5095 /tmp/all-ips-to-block.txt
+```
+
+- Then I added them to the normal ipset we are already using with firewalld
+ - I will check again in a few hours and ban more
+
diff --git a/docs/2021-06/index.html b/docs/2021-06/index.html
index 5764ddded..4fb8a73d0 100644
--- a/docs/2021-06/index.html
+++ b/docs/2021-06/index.html
@@ -6,29 +6,35 @@
-
-
+
-
-
+
+
-
-
+
@@ -38,11 +44,11 @@ COPY 20994
{
"@context": "http://schema.org",
"@type": "BlogPosting",
- "headline": "July, 2021",
+ "headline": "June, 2021",
"url": "https://alanorth.github.io/cgspace-notes/2021-06/",
- "wordCount": "2439",
- "datePublished": "2021-06-01T08:53:07+03:00",
- "dateModified": "2021-07-11T15:59:16+03:00",
+ "wordCount": "3505",
+ "datePublished": "2021-06-01T10:51:07+03:00",
+ "dateModified": "2021-07-01T08:53:21+03:00",
"author": {
"@type": "Person",
"name": "Alan Orth"
@@ -55,7 +61,7 @@ COPY 20994
-
Export another list of ALL subjects on CGSpace, including AGROVOC and non-AGROVOC for Enrico:
-
-
localhost/dspace63= > \COPY (SELECT DISTINCT LOWER(text_value) AS subject, count(*) FROM metadatavalue WHERE dspace_object_id in (SELECT dspace_object_id FROM item) AND metadata_field_id IN (119, 120, 127, 122, 128, 125, 135, 203, 208, 210, 215, 123, 236, 242, 187) GROUP BY subject ORDER BY count DESC) to /tmp/2021-07-01-all-subjects.csv WITH CSV HEADER;
-COPY 20994
-
2021-07-04
+
IWMI notified me that AReS was down with an HTTP 502 error
-
Update all Docker containers on the AReS server (linode20) and rebuild OpenRXV:
+
Looking at UptimeRobot I see it has been down for 33 hours, but I never got a notification
+
I don’t see anything in the Elasticsearch container logs, or the systemd journal on the host, but I notice that the angular_nginx container isn’t running
Rebuild DSpace Test (linode26) from a fresh Ubuntu 20.04 image on Linode
-
The start plugins on AReS had seventy-five errors from the dspace_add_missing_items plugin for some reason so I had to start a fresh indexing
-
I noticed that the WorldFish data has dozens of incorrect countries so I should talk to Salem about that because they manage it
-
-
Also I noticed that we weren’t using the Country formatter in OpenRXV for the WorldFish country field, so some values don’t get mapped properly
-
I added some value mappings to fix some issues with WorldFish data and added a few more fields to the repository harvesting config and started a fresh re-indexing
+
I guess this is related to the SMTP issues last week
+
I had fixed the config, but didn’t restart Tomcat so DSpace didn’t load the new variables
+
I ran all system updates on CGSpace (linode18) and DSpace Test (linode26) and rebooted the servers
-
2021-07-05
+
2021-06-03
-
The AReS harvesting last night succeeded and I started the plugins
-
Margarita from CCAFS asked if we can create a new field for AICCRA publications
+
Meeting with AMCOW and IWMI to discuss AMCOW getting IWMI’s content into the new AMCOW Knowledge Hub
-
I asked her to clarify what they want
-
AICCRA is an initiative so it might be better to create new field for that, for example cg.contributor.initiative
+
At first we spent some time talking about DSpace communities/collections and the REST API, but then they said they actually prefer to send queries to sites on the fly and cache them in Redis for some time
+
That’s when I thought they could perhaps use the OpenSearch, but I can’t remember if it’s possible to limit by community, or only collection…
+
Looking now, I see there is a “scope” parameter that can be used for community or collection, for example:
That will sort by date issued (see: webui.itemlist.sort-option.2 in dspace.cfg), give 100 results per page, and start on item 1
+
Otherwise, another alternative would be to use the IWMI CSV that we are already exporting every week
+
Fill out the CGIAR-AGROVOC Task Group: Survey on the current CGIAR use of AGROVOC survey on behalf of CGSpace
+
+
2021-06-06
-
Atmire merged my spider user agent changes from last month so I will update the example list we use in DSpace and remove the new ones from my ilri override file
+
The Elasticsearch indexes are messed up so I dumped and re-created them correctly:
Also, I concatenated all our user agents into one file and purged all hits:
+
The harvesting on AReS completed successfully
+
Provide feedback to FAO on how we use AGROVOC for their “AGROVOC call for use cases”
+
+
2021-06-10
+
+
Skype with Moayad to discuss AReS harvesting improvements
+
+
He will work on a plugin that reads the XML sitemap to get all item IDs and checks whether we have them or not
-
$ ./ilri/check-spider-hits.sh -f /tmp/spiders -p
-Purging 95 hits from Drupal in statistics
-Purging 38 hits from DTS Agent in statistics
-Purging 601 hits from Microsoft Office Existence Discovery in statistics
-Purging 51 hits from Site24x7 in statistics
-Purging 62 hits from Trello in statistics
-Purging 13574 hits from WhatsApp in statistics
-Purging 144 hits from FlipboardProxy in statistics
-Purging 37 hits from LinkWalker in statistics
-Purging 1 hits from [Ll]ink.?[Cc]heck.? in statistics
-Purging 427 hits from WordPress in statistics
+
2021-06-14
+
+
Dump and re-create indexes on AReS (as above) so I can do a harvest
+
+
2021-06-16
+
+
Looking at the Solr statistics on CGSpace for last month I see many requests from hosts using seemingly normal Windows browser user agents, but using the MSN bot’s DNS
+
+
For example, user agent Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.0; Trident/5.0; Trident/5.0) with DNS msnbot-131-253-25-91.search.msn.com.
+
I queried Solr for all hits using the MSN bot DNS (dns:*msnbot* AND dns:*.msn.com.) and found 457,706
+
I extracted their IPs using Solr’s CSV format and ran them through my resolve-addresses.py script and found that they all belong to MICROSOFT-CORP-MSN-AS-BLOCK (AS8075)
I purged the hits with ilri/check-spider-ip-hits.sh (though I had to do it in 3 batches because I forgot to increase the facet.limit so I was only getting them 100 at a time)
+
+
+
Moayad sent a pull request a few days ago to re-work the harvesting on OpenRXV
+
+
It will hopefully also fix the duplicate and missing items issues
+
I had a Skype with him to discuss
+
I got it running on podman-compose, but I had to fix the storage permissions on the Elasticsearch volume after the first time it tries (and fails) to run:
Some appear twice in the Elasticsearch index, but appear in only one collection
+
Some appear twice in the Elasticsearch index, and appear in two collections
+
Some appear twice in the Elasticsearch index, but appear in three collections (!)
+
+
+
So really we need to just check whether a handle exists before we insert it
+
I tested the pull request for DS-1977 that adjusts the sitemap generation code to exclude private items
+
+
It applies cleanly and seems to work, but we don’t actually have any private items
+
The issue we are having with AReS hitting restricted items in the sitemap is that the items have restricted metadata, not that they are private
+
+
+
Testing the pull request for DS-4065 where the REST API’s /rest/items endpoint is not aware of private items and returns an incorrect number of items
+
+
This is most easily seen by setting a low limit in /rest/items, making one of the items private, and requesting items again with the same limit
+
I confirmed the issue on the current DSpace 6 Demo:
Make a pull request to the COUNTER-Robots project to add two new user agents: crusty and newspaper
+
+
These two bots have made ~3,000 requests on CGSpace
+
Then I added them to our local bot override in CGSpace (until the above pull request is merged) and ran my bot checking script:
+
+
+
+
$ ./ilri/check-spider-hits.sh -f dspace/config/spiders/agents/ilri -p
+Purging 1339 hits from RI\/1\.0 in statistics
+Purging 447 hits from crusty in statistics
+Purging 3736 hits from newspaper in statistics
-Total number of bot hits purged: 15030
+Total number of bot hits purged: 5522
-
Meet with the CGIAR–AGROVOC task group to discuss how we want to do the workflow for submitting new terms to AGROVOC
-
I extracted another list of all subjects to check against AGROVOC:
-
-
\COPY (SELECT DISTINCT(LOWER(text_value)) AS subject, count(*) FROM metadatavalue WHERE dspace_object_id in (SELECT dspace_object_id FROM item) AND metadata_field_id IN (119, 120, 127, 122, 128, 125, 135, 203, 208, 210, 215, 123, 236, 242, 187) GROUP BY subject ORDER BY count DESC) to /tmp/2021-07-06-all-subjects.csv WITH CSV HEADER;
-$ csvcut -c 1 /tmp/2021-07-06-all-subjects.csv | sed 1d > /tmp/2021-07-06-all-subjects.txt
-$ ./ilri/agrovoc-lookup.py -i /tmp/2021-07-06-all-subjects.txt -o /tmp/2021-07-06-agrovoc-results-all-subjects.csv -d
-
Looking into the database issues we had last month on 2021-06-23
+
These bots account for ~42,000 hits in our statistics… I will just purge them and add them to our local override, but I can’t be bothered to submit them to COUNTER-Robots since I’d have to look up the information for each one
+
I re-synced DSpace Test (linode26) with the assetstore, Solr statistics, and database from CGSpace (linode18)
+
+
2021-06-23
-
I think it might have been some kind of attack because the number of XMLUI sessions was through the roof at one point (10,000!) and the number of unique IPs accessing the server that day is much higher than any other day:
+
I woke up this morning to find CGSpace down
+
+
The logs show a high number of abandoned PostgreSQL connections and locks:
I deployed the new OpenRXV code on CGSpace but I’m having problems with the indexing, something about missing the mappings on the openrxv-items-temp index
+
+
I extracted the mappings from my local instance using elasticdump and after putting them on CGSpace I was able to harvest…
+
But still, there are way too many duplicates and I’m not sure what the actual number of items should be
+
According to the OAI ListRecords for each of our repositories, we should have about:
+
+
MELSpace: 9537
+
WorldFish: 4483
+
CGSpace: 91305
+
Total: 105325
+
+
+
Looking at the last backup I have from harvesting before these changes we have 104,000 total handles, but only 99186 unique:
So the harvest on the live site is missing items, then why didn’t the add missing items plugin find them?!
-
Atmire plans to debug the database connection issues on CGSpace (linode18) today so they asked me to make the REST API inaccessible for today and tomorrow
-
-
I adjusted nginx to give an HTTP 403 as well as a an error message to contact me
+
I notice that we are missing the type in the metadata structure config for each repository on the production site, and we are using type for item type in the actual schema… so maybe there is a conflict there
+
I will rename type to item_type and add it back to the metadata structure
+
The add missing items definitely checks this field…
+
I modified my local backup to add type: item and uploaded it to the temp index on production
+
Oh! nginx is blocking OpenRXV’s attempt to read the sitemap:
I fixed nginx so it always allows people to get the sitemap and then re-ran the plugins… now it’s checking 180,000+ handles to see if they are collections or items…
-
Start an indexing on AReS
+
I see it fetched the sitemap three times, we need to make sure it’s only doing it once for each repository
-
2021-07-17
+
+
According to the api logs we will be adding 5,697 items:
Spent a few hours with Moayad troubleshooting and improving OpenRXV
-
I’m in Cyprus mostly offline, but I noticed that CGSpace was down
-
-
I checked and there was a blank white page with HTTP 200
-
There are thousands of locks in PostgreSQL:
+
We found a bug in the harvesting code that can occur when you are harvesting DSpace 5 and DSpace 6 instances, as DSpace 5 uses numeric (long) IDs, and DSpace 6 uses UUIDs
-
postgres@linode18:~$ psql -c 'SELECT * FROM pg_locks pl LEFT JOIN pg_stat_activity psa ON pl.pid = psa.pid;' | wc -l
-2302
-postgres@linode18:~$ psql -c 'SELECT * FROM pg_locks pl LEFT JOIN pg_stat_activity psa ON pl.pid = psa.pid;' | wc -l
-2564
-postgres@linode18:~$ psql -c 'SELECT * FROM pg_locks pl LEFT JOIN pg_stat_activity psa ON pl.pid = psa.pid;' | wc -l
-2530
-
I ran all updates on the server (linode18) and restarted it, then DSpace came back up
-
I sent a message to Atmire, as I never heard from them last week when we blocked access to the REST API for two days for them to investigate the server issues
-
Clone the openrxv-items-temp index on AReS and re-run all the plugins, but most of the “dspace_add_missing_items” tasks failed so I will just run a full re-harvest
-
The load on CGSpace is 45.00… the nginx access.log is going so fast I can’t even read it
+
2021-06-25
-
I see lots of IPs from AS206485 that are changing their user agents (Linux, Windows, macOS…)
-
This is finegroupservers.com aka “UGB - UGB Hosting OU”
-
I will get a list of their IP blocks from ipinfo.app and block them in nginx
-
There is another group of IPs that are owned by an ISP called “TrafficTransitSolution LLC” that does not have its own ASN unfortunately
-
“TrafficTransitSolution LLC” seems to be affiliated with AS206485 (UGB Hosting OU) anyways, but they sometimes use AS49453 Global Layer B.V.G also
-
I found a tool that lets you grep a file by CIDR, so I can use that to purge hits from Solr eventually:
+
The new OpenRXV code creates almost 200,000 jobs when the plugins start
+
+
I figured out how to use bee-queue/arena to view our Bull job queue
+
Also, we can see the jobs directly using redis-cli:
I found a few people complaining about these Russian attacks too:
+
We can apparently get the names of the jobs in each hash using hget:
+
+
127.0.0.1:6379> TYPE bull:plugins:401827
+hash
+127.0.0.1:6379> HGET bull:plugins:401827 name
+"dspace_add_missing_items"
+
+
I whipped up a one liner to get the keys for all plugin jobs, convert to redis HGET commands to extract the value of the name field, and then sort them by their counts:
Note that this uses ncat to send commands directly to redis all at once instead of one at a time (netcat didn’t work here, as it doesn’t know when our input is finished and never quits)
I thought of using redis-cli --pipe but then you have to construct the commands in the redis protocol format with the number of args and length of each command
-
According to AbuseIPDB.com and whois data provided by the asn tool, I see these organizations, networks, and ISPs all seem to be related:
-
Looking into the spike in PostgreSQL connections last week
+
+
I see the same things that I always see (large number of connections waiting for lock, large number of threads, high CPU usage, etc), but I also see almost 10,000 DSpace sessions on 2021-06-25
I will download blocklists for all these except Ethiopian Telecom, Quadranet, and Amazon, though I’m concerned about Global Layer because it’s a huge ASN that seems to have legit hosts too…?
+
2021-06-30
+
+
CGSpace is showing a blank white page…
+
+
The status is HTTP 200, but it’s blank white… so UptimeRobot didn’t send a notification!
I deployed the block list on CGSpace (linode18) and the load is down to 1.0 but I see there are still some DDoS IPs getting through… sigh
-
The next thing I need to do is purge all the IPs from Solr using grepcidr…
+
The first one of these I see is from last night at 2021-06-29 at 10:47 PM
+
I restarted Tomcat 7 and CGSpace came back up…
+
I didn’t see that Atmire had responded last week (on 2021-06-23) about the issues we had
+
+
He said they had to do the same thing that they did last time: switch to the postgres user and kill all activity
+
He said they found tons of connections to the REST API, like 3-4 per second, and asked if that was normal
+
I pointed him to our Tomcat server.xml configuration, saying that we purposefully isolated the Tomcat connection pools between the API and XMLUI for this purpose…
+
+
+
Export a list of all CGSpace’s AGROVOC keywords with counts for Enrico and Elizabeth Arnaud to discuss with AGROVOC:
+
+
localhost/dspace63= > \COPY (SELECT DISTINCT text_value AS "dcterms.subject", count(*) FROM metadatavalue WHERE dspace_object_id in (SELECT dspace_object_id FROM item) AND metadata_field_id = 187 GROUP BY "dcterms.subject" ORDER BY count DESC) to /tmp/2021-06-30-agrovoc.csv WITH CSV HEADER;
+COPY 20780
+
+
Actually Enrico wanted NON AGROVOC, so I extracted all the center and CRP subjects (ignoring system office and themes):
+
+
localhost/dspace63= > \COPY (SELECT DISTINCT LOWER(text_value) AS subject, count(*) FROM metadatavalue WHERE dspace_object_id in (SELECT dspace_object_id FROM item) AND metadata_field_id IN (119, 120, 127, 122, 128, 125, 135, 203, 208, 210, 215, 123, 236, 242) GROUP BY subject ORDER BY count DESC) to /tmp/2021-06-30-non-agrovoc.csv WITH CSV HEADER;
+COPY 1710
+
+
Fix an issue in the Ansible infrastructure playbooks for the DSpace role
+
+
It was causing the template module to fail when setting up the npm environment
+
We needed to install acl so that Ansible can use setfacl on the target file before becoming an unprivileged user
+
+
+
I saw a strange message in the Tomcat 7 journal on DSpace Test (linode26):
+
+
Jun 30 16:00:09 linode26 tomcat7[30294]: WARNING: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [111,733] milliseconds.
+
+
What’s even crazier is that it is twice that on CGSpace (linode18)!
+
Apparently OpenJDK defaults to using /dev/random (see /etc/java-8-openjdk/security/java.security):
+
+
securerandom.source=file:/dev/urandom
+
+
/dev/random blocks and can take a long time to get entropy, and urandom on modern Linux is a cryptographically secure pseudorandom number generator
+
+
Now Tomcat starts much faster and no warning is printed so I’m going to add this to our Ansible infrastructure playbooks