sofa icon indicating copy to clipboard operation
sofa copied to clipboard

RSS Feed per OS

Open johnnyramos opened this issue 9 months ago • 4 comments

Taking a first stab at getting an RSS feed generated while building the structured data feed. Let me know what you all think and if it's the right direction here. This created two separate feeds based on OS type. Wondering if maybe one is better with all data imported from the json files, then create an icon at the top right for RSS.

Feedback is welcome!

Description

This RSS feed will consist of all Security Releases from each version of the OS. build-sofa-feed.py will take the feed_structure data and sort it out by creating a new list that just consists of SecurityReleases and sorts them by ReleaseDate but ignoring entries inside that have a string Preinstalled as the ReleaseData. In this case, macOS 12.

It then uses feedgen module to create the XML that will be used as the RSS feed within the write_data_to_rss function. RSS feed entries usually get sorted by publish dates, so in this case - we use the ReleaseDate as the publish date.

Changes

build-sofa-feed.py

sort_by_release_date

  • Regenerating a new list with just SecurityReleases
  • Sorting by ReleaseDate while ignoring Preinstalled string
  • Returning list of all OS SecurityReleases or empty if error

write_data_to_rss

  • Using feedgen python module
  • Escape if empty list given
  • Generate new RSS file with sorted list given
  • Pretty the description just like the site has
  • If Preinstall string, set old date. This is just accounting for old entry but might need tweaking if we see this often. Hoping not.
  • Create feed and export to xml file

index.html

  • Added link below the machine readable data one
  • I noticed @headmin created a function here to load last checked date. Will it be a standard to create functions for load to handle error checking?

README.md

Updated to account for RSS Feed

docker workflows

  • Accounting for new files generated and copied over

requirements.txt

  • Adding the feedgen module

Tests

We ran the following lines to create the new xml files along with json files. Copied them into the v1 directory for the webserver to pick up in testing.

python3 ./build-sofa-feed.py iOS
python3 ./build-sofa-feed.py macOS

Established a webserver to view changes.

➜  sofa git:(rss_feed) ✗ sudo python3 -m http.server 80
[sudo] password for jramos:
Serving HTTP on 0.0.0.0 port 80 (http://0.0.0.0:80/) ...
127.0.0.1 - - [07/May/2024 00:21:55] "GET / HTTP/1.1" 304 -
127.0.0.1 - - [07/May/2024 00:21:55] "GET /config.json HTTP/1.1" 304 -
127.0.0.1 - - [07/May/2024 00:21:55] "GET /v1/timestamp.json HTTP/1.1" 200 -
127.0.0.1 - - [07/May/2024 00:21:58] "GET /v1/macos_rss_feed.xml HTTP/1.1" 200 -
127.0.0.1 - - [07/May/2024 00:22:02] "GET /v1/timestamp.json HTTP/1.1" 304 -
127.0.0.1 - - [07/May/2024 00:22:03] "GET /v1/ios_rss_feed.xml HTTP/1.1" 200 -

Docker build of image/

➜  sofa git:(main) ✗ docker build -t sofa_jramos .
[+] Building 15.8s (20/20) FINISHED                                                                                                                                       docker:default
 => [internal] load build definition from dockerfile                                                                                                                                0.0s
 => => transferring dockerfile: 1.19kB                                                                                                                                              0.0s
 => [internal] load metadata for docker.io/library/python:3.12-alpine                                                                                                               2.1s
 => [internal] load .dockerignore                                                                                                                                                   0.0s
 => => transferring context: 2B                                                                                                                                                     0.0s
 => [internal] load build context                                                                                                                                                   0.0s
 => => transferring context: 56.57kB                                                                                                                                                0.0s
 => [ 1/15] FROM docker.io/library/python:3.12-alpine@sha256:ef097620baf1272e38264207003b0982285da3236a20ed829bf6bbf1e85fe3cb                                                       3.6s
 => => resolve docker.io/library/python:3.12-alpine@sha256:ef097620baf1272e38264207003b0982285da3236a20ed829bf6bbf1e85fe3cb                                                         0.0s
 => => sha256:ef097620baf1272e38264207003b0982285da3236a20ed829bf6bbf1e85fe3cb 1.65kB / 1.65kB                                                                                      0.0s
 => => sha256:c583b8590a197db1f6efece2dd244b0259cb6f82c4acc654bfbe48e00e20a7b9 1.37kB / 1.37kB                                                                                      0.0s
 => => sha256:f44387b482817f41bdac1892c45711adaedb3a7dd381844cdc3f360e66314d7a 6.02kB / 6.02kB                                                                                      0.0s
 => => sha256:4abcf20661432fb2d719aaf90656f55c287f8ca915dc1c92ec14ff61e67fbaf8 3.41MB / 3.41MB                                                                                      0.8s
 => => sha256:c3cdf40b8bda8e4ca4be0f5fa7f1d128907271efcbc72cbfc7c8b0f939ec25ea 619.60kB / 619.60kB                                                                                  0.3s
 => => sha256:3a6cecfe70039fd21206783553d33ea4753700f031a2490428311619801d02f7 13.96MB / 13.96MB                                                                                    2.5s
 => => sha256:60d2faee92e78fe7518f0ff1645cd7320bf6b140ff885fdec2a1ea1d878f0dca 239B / 239B                                                                                          0.6s
 => => sha256:b62713ed4827911d38bb5a9ac322efa0408b4bb135863b4b15c4bc383e59918b 2.70MB / 2.70MB                                                                                      1.9s
 => => extracting sha256:4abcf20661432fb2d719aaf90656f55c287f8ca915dc1c92ec14ff61e67fbaf8                                                                                           0.2s
 => => extracting sha256:c3cdf40b8bda8e4ca4be0f5fa7f1d128907271efcbc72cbfc7c8b0f939ec25ea                                                                                           0.4s
 => => extracting sha256:3a6cecfe70039fd21206783553d33ea4753700f031a2490428311619801d02f7                                                                                           0.7s
 => => extracting sha256:60d2faee92e78fe7518f0ff1645cd7320bf6b140ff885fdec2a1ea1d878f0dca                                                                                           0.0s
 => => extracting sha256:b62713ed4827911d38bb5a9ac322efa0408b4bb135863b4b15c4bc383e59918b                                                                                           0.3s
 => [ 2/15] WORKDIR /app                                                                                                                                                            0.1s
 => [ 3/15] COPY build-sofa-feed.py /app/                                                                                                                                           0.0s
 => [ 4/15] COPY process_uma.py /app/                                                                                                                                               0.0s
 => [ 5/15] COPY config.json /app/                                                                                                                                                  0.0s
 => [ 6/15] COPY feed_structure_template_v1.yaml /app/                                                                                                                              0.0s
 => [ 7/15] COPY forked_builds.json /app/                                                                                                                                           0.0s
 => [ 8/15] COPY sofa-time-series.py /app/                                                                                                                                          0.0s
 => [ 9/15] COPY requirements.txt /app/                                                                                                                                             0.0s
 => [10/15] RUN touch time-series.csv || true                                                                                                                                       0.3s
 => [11/15] COPY time-series.csv /app/                                                                                                                                              0.0s
 => [12/15] COPY model_identifier_*.json /app/                                                                                                                                      0.0s
 => [13/15] RUN pip install --no-cache-dir -r requirements.txt                                                                                                                      8.6s
 => [14/15] COPY entrypoint.sh /app/                                                                                                                                                0.0s
 => [15/15] RUN chmod +x /app/entrypoint.sh                                                                                                                                         0.4s
 => exporting to image                                                                                                                                                              0.3s
 => => exporting layers                                                                                                                                                             0.3s
 => => writing image sha256:24ce704610bd4a391bcdfe013a3ec855f4c9ee7b25c5a1cfabe19f3177df1a5a                                                                                        0.0s
 => => naming to docker.io/library/sofa_jramos

Visuals

Screenshot 2024-05-06 233149 Screenshot 2024-05-06 233249 Screenshot 2024-05-06 233204 Screenshot 2024-05-06 233233 Screenshot 2024-05-07 001724 Screenshot 2024-05-07 001736 Screenshot 2024-05-07 002902

johnnyramos avatar May 07 '24 07:05 johnnyramos