QubesOS / qubes-issues

The Qubes OS Project issue tracker
https://www.qubes-os.org/doc/issue-tracking/
526 stars 46 forks source link

feedstail used in canary proof_of_freshness_generator.sh is a dead package #5040

Closed marmarek closed 4 years ago

marmarek commented 5 years ago

Affected component(s) or functionality (if applicable) qubes-secpack

Brief summary feedstail is a dead package. It's removed from Fedora 30. It isn't available in Debian either. A replacement needs to be found.

esote commented 5 years ago

@marmarek I wrote one possible solution using Go:

package main

import (
    "fmt"
    "log"

    "github.com/mmcdole/gofeed"
)

func main() {
    parser := gofeed.NewParser()
    urls := []string{
        "https://www.spiegel.de/international/index.rss",
        "https://rss.nytimes.com/services/xml/rss/nyt/World.xml",
        "https://feeds.bbci.co.uk/news/world/rss.xml",
        "http://feeds.reuters.com/reuters/worldnews",
    }

    count := 5

    for n, url := range urls {
        feed, err := parser.ParseURL(url)

        if err != nil {
            log.Fatal(err)
        }

        if len(feed.Items) < count {
            log.Fatalf("couldn't find %d items", count)
        }

        if n > 0 {
            fmt.Println()
        }

        fmt.Printf("Src: %s (%s)\n---\n", feed.Title, url)

        for i := 0; i < count; i++ {
            fmt.Printf("%s\n", feed.Items[i].Title)
        }
    }
}

Output:

Source: SPIEGEL ONLINE - International (https://www.spiegel.de/international/index.rss)
-----
The Road to Brussels: Does Von der Leyen Have a Chance as Commission President?
More Inhumane than Trump: Europe's Treatment of Migrants Is Shameful
The World's Bank: Vast Chinese Loans Pose Risks to Developing World
No Way Back: Why Most Syrian Refugees Want to Stay in Germany
Lifelong Refugees: Ethiopia Is the Ultimate Destination for Many Fleeing Home

Source: NYT > World News (https://rss.nytimes.com/services/xml/rss/nyt/World.xml)
-----
Iran Announces New Breach of Nuclear Deal Limits, and Threatens Further Violations
Greek Elections: Long Economic Crisis Set to Usher In New Leadership
A Political Murder and Far-Right Terrorism: Germany’s New Hateful Reality
Hong Kong Protesters Take Their Message to Chinese Tourists
In Leak, U.K. Ambassador Calls Trump Administration ‘Inept’ and ‘Clumsy’

Source: BBC News - World (https://feeds.bbci.co.uk/news/world/rss.xml)
-----
Greek elections: New Democracy 'on course for majority'
Iran nuclear deal: Government announces enrichment breach
Jeffrey Epstein: US financier 'charged with sex trafficking'
San Fermín: Three gored during annual Pamplona bull run
China denies Muslim separation campaign in Xinjiang

Source: Reuters: World News (http://feeds.reuters.com/reuters/worldnews)
-----
Wife of China's Meng, former Interpol chief, sues agency
UK lawmakers weigh up options to try to block a no deal Brexit
6.9 magnitude quake strikes in eastern Indonesia, tsunami alert issued
Malta to relocate migrants on German rescue ship
German conservative boss warns coalition partners on Europe

A downside is that it requires an external dependency (github.com/mmcdole/gofeed) for parsing the feeds. But I'm not sure that matters if only the output is important.

Thoughts?

esote commented 5 years ago

Since I know a lot of Qubes uses Python, here is the same thing in Python, with an external dependency on feedparser:

import feedparser

urls = [
    "https://www.spiegel.de/international/index.rss",
    "https://rss.nytimes.com/services/xml/rss/nyt/World.xml",
    "https://feeds.bbci.co.uk/news/world/rss.xml",
    "http://feeds.reuters.com/reuters/worldnews",
]

count = 5

for n, url in enumerate(urls):
    feed = feedparser.parse(url)

    if len(feed["items"]) < count:
        sys.exit("couldn't find {:d} items".format(count))

    if n > 0:
        print()

    print("Source: {:s} ({:s})\n---".format(feed["feed"]["title"], url))

    for i in range(count):
        print(feed["items"][i]["title"])

If this ends up being suitable, let me know and I can submit a PR.

marmarek commented 4 years ago

If this ends up being suitable, let me know and I can submit a PR.

Yes, please :)