diff --git a/PROJECTS/intermediate/security-news-scraper/.github/workflows/release.yml b/PROJECTS/intermediate/security-news-scraper/.github/workflows/release.yml new file mode 100644 index 00000000..f77de352 --- /dev/null +++ b/PROJECTS/intermediate/security-news-scraper/.github/workflows/release.yml @@ -0,0 +1,32 @@ +# ©AngelaMos | 2026 +# release.yml + +name: release + +on: + push: + tags: + - "v*" + +permissions: + contents: write + +jobs: + goreleaser: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - uses: actions/setup-go@v5 + with: + go-version-file: go.mod + + - uses: goreleaser/goreleaser-action@v6 + with: + distribution: goreleaser + version: "~> v2" + args: release --clean + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/PROJECTS/intermediate/security-news-scraper/.gitignore b/PROJECTS/intermediate/security-news-scraper/.gitignore new file mode 100644 index 00000000..d938e12c --- /dev/null +++ b/PROJECTS/intermediate/security-news-scraper/.gitignore @@ -0,0 +1,27 @@ +# ©AngelaMos | 2026 +# .gitignore + +# private dev + research material (never public) +docs/ + +# Go build artifacts +/nadezhda +/bin/ +*.test +*.out +*.prof + +# local runtime data (SQLite store + WAL sidecars) +*.db +*.db-wal +*.db-shm +*.sqlite +/data/ + +# large local KEV catalog snapshot (manual download; tests use kev-sample.json) +/testdata/kev/kev-full.json + +# env / secrets / local overrides +.env +*.local.yaml +config.local.yaml diff --git a/PROJECTS/intermediate/security-news-scraper/.goreleaser.yaml b/PROJECTS/intermediate/security-news-scraper/.goreleaser.yaml new file mode 100644 index 00000000..af2df796 --- /dev/null +++ b/PROJECTS/intermediate/security-news-scraper/.goreleaser.yaml @@ -0,0 +1,45 @@ +# ©AngelaMos | 2026 +# .goreleaser.yaml + +version: 2 + +project_name: nadezhda + +before: + hooks: + - go mod tidy + +builds: + - id: nadezhda + main: ./cmd/nadezhda + binary: nadezhda + env: + - CGO_ENABLED=0 + goos: [linux, darwin] + goarch: [amd64, arm64] + ldflags: + - -s -w -X github.com/CarterPerez-dev/nadezhda/internal/version.Version={{ .Version }} + +archives: + - id: nadezhda + name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}" + formats: [tar.gz] + files: + - README.md + - LICENSE + +checksum: + name_template: "checksums.txt" + +changelog: + sort: asc + filters: + exclude: + - "^docs:" + - "^test:" + - "^chore:" + +release: + github: + owner: CarterPerez-dev + name: nadezhda diff --git a/PROJECTS/intermediate/security-news-scraper/LICENSE b/PROJECTS/intermediate/security-news-scraper/LICENSE new file mode 100644 index 00000000..0ad25db4 --- /dev/null +++ b/PROJECTS/intermediate/security-news-scraper/LICENSE @@ -0,0 +1,661 @@ + GNU AFFERO GENERAL PUBLIC LICENSE + Version 3, 19 November 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU Affero General Public License is a free, copyleft license for +software and other kinds of works, specifically designed to ensure +cooperation with the community in the case of network server software. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +our General Public Licenses are intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + Developers that use our General Public Licenses protect your rights +with two steps: (1) assert copyright on the software, and (2) offer +you this License which gives you legal permission to copy, distribute +and/or modify the software. + + A secondary benefit of defending all users' freedom is that +improvements made in alternate versions of the program, if they +receive widespread use, become available for other developers to +incorporate. Many developers of free software are heartened and +encouraged by the resulting cooperation. However, in the case of +software used on network servers, this result may fail to come about. +The GNU General Public License permits making a modified version and +letting the public access it on a server without ever releasing its +source code to the public. + + The GNU Affero General Public License is designed specifically to +ensure that, in such cases, the modified source code becomes available +to the community. It requires the operator of a network server to +provide the source code of the modified version running there to the +users of that server. Therefore, public use of a modified version, on +a publicly accessible server, gives the public access to the source +code of the modified version. + + An older license, called the Affero General Public License and +published by Affero, was designed to accomplish similar goals. This is +a different license, not a version of the Affero GPL, but Affero has +released a new version of the Affero GPL which permits relicensing under +this license. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU Affero General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Remote Network Interaction; Use with the GNU General Public License. + + Notwithstanding any other provision of this License, if you modify the +Program, your modified version must prominently offer all users +interacting with it remotely through a computer network (if your version +supports such interaction) an opportunity to receive the Corresponding +Source of your version by providing access to the Corresponding Source +from a network server at no charge, through some standard or customary +means of facilitating copying of software. This Corresponding Source +shall include the Corresponding Source for any work covered by version 3 +of the GNU General Public License that is incorporated pursuant to the +following paragraph. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the work with which it is combined will remain governed by version +3 of the GNU General Public License. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU Affero General Public License from time to time. Such new versions +will be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU Affero General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU Affero General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU Affero General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If your software can interact with users remotely through a computer +network, you should also make sure that it provides a way for users to +get its source. For example, if your program is a web application, its +interface could display a "Source" link that leads users to an archive +of the code. There are many ways you could offer source, and different +solutions will be better for different programs; see section 13 for the +specific requirements. + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU AGPL, see +. diff --git a/PROJECTS/intermediate/security-news-scraper/README.md b/PROJECTS/intermediate/security-news-scraper/README.md new file mode 100644 index 00000000..7c96ed7a --- /dev/null +++ b/PROJECTS/intermediate/security-news-scraper/README.md @@ -0,0 +1,201 @@ + + + +```json +███╗ ██╗ █████╗ ██████╗ ███████╗███████╗██╗ ██╗██████╗ █████╗ +████╗ ██║██╔══██╗██╔══██╗██╔════╝╚══███╔╝██║ ██║██╔══██╗██╔══██╗ +██╔██╗ ██║███████║██║ ██║█████╗ ███╔╝ ███████║██║ ██║███████║ +██║╚██╗██║██╔══██║██║ ██║██╔══╝ ███╔╝ ██╔══██║██║ ██║██╔══██║ +██║ ╚████║██║ ██║██████╔╝███████╗███████╗██║ ██║██████╔╝██║ ██║ +╚═╝ ╚═══╝╚═╝ ╚═╝╚═════╝ ╚══════╝╚══════╝╚═╝ ╚═╝╚═════╝ ╚═╝ ╚═╝ +``` + +[![Cybersecurity Projects](https://img.shields.io/badge/Cybersecurity--Projects-Project%20%2339-red?style=flat&logo=github)](https://github.com/CarterPerez-dev/Cybersecurity-Projects/tree/main/PROJECTS/intermediate/security-news-scraper) +[![Go](https://img.shields.io/badge/Go-1.25-00ADD8?style=flat&logo=go&logoColor=white)](https://go.dev) +[![Keyless](https://img.shields.io/badge/enrichment-keyless-4B7BEC?style=flat)](https://www.cisa.gov/known-exploited-vulnerabilities-catalog) +[![Single static binary](https://img.shields.io/badge/binary-single%20static-6d4aff?style=flat)](https://pkg.go.dev/modernc.org/sqlite) +[![License: AGPLv3](https://img.shields.io/badge/License-AGPL_v3-purple.svg)](https://www.gnu.org/licenses/agpl-3.0) + +> A keyless security-news and CVE intelligence engine in Go. Point it at a set of RSS and Atom feeds and it fetches them politely, clusters the same story as it breaks across outlets, extracts every CVE it mentions, enriches each one with authoritative exploit intelligence, ranks the whole set by what actually matters, and hands you a browsable dossier in your terminal. It ships as a single static binary over a local SQLite store, needs no API key to do any of it, and treats the news as the product with the CVE data as the intelligence that sharpens it. + +

+ The nadezhda terminal UI: a ranked, color-coded dossier of security news, with per-story scores, source dots, and CVE severity +

+ +## Why aggregate security news + +There is more security news published every day than any person can read, and almost all of it is noise relative to the one story that matters to you right now. The hard problem is not gathering headlines. It is deciding which three of the four hundred you should act on before lunch. + +The signal is usually some combination of the same few factors. A vulnerability that many outlets picked up in the same few hours is trending for a reason. A CVE that CISA just added to its Known Exploited Vulnerabilities catalog is being used against real targets today. A flaw with a high EPSS score is one the rest of the world is about to start exploiting. Nadezhda computes that combination and sorts by it, so a CVSS 6.5 that is on the KEV catalog can outrank a CVSS 9.8 that nobody has touched. + +The cost of missing that signal is not hypothetical. Log4Shell went from a GitHub issue to every security outlet on earth within hours and landed on the KEV catalog almost immediately; a tool that ranks by cross-outlet velocity plus KEV plus EPSS floats it to the top of the first scrape. Equifax fell to a known Apache Struts flaw that had a patch available for months, and the intelligence to prioritize it sat in public feeds the whole time, so the failure was one of triage, not of information. MOVEit was mass-exploited in a tight window where the advisories, the KEV listing, and the coverage all arrived together. Velocity was the tell. + +## What it is + +This is not a stub. It ingests real feeds, enriches real CVEs from keyless authoritative sources, clusters and ranks real coverage, and surfaces it four ways. Every capability below is exercised by unit tests, offline fixture-driven tests, and a live run against the real feeds. + +**Ingestion** +- Seven seeded RSS/Atom feeds (Krebs on Security, The Hacker News, BleepingComputer, SecurityWeek, Dark Reading, The Register, CISA), fetched concurrently through a per-host rate limiter with an honest User-Agent +- Conditional GET: an unchanged feed answers `304 Not Modified` and costs almost nothing, and a retry honors `Retry-After` and never retries a timeout or a cancellation +- Fail-soft by construction: one broken feed is reported at the end and never aborts the run, and every article deduplicates at the database on both its canonical URL and a content hash + +**Enrichment, keyless by default** +- CVE core from the CVE Program's cvelistV5 records: a CVSS score resolved by a fixed version precedence (v4.0, then v3.1, then v3.0, then v2.0) read across both the vendor and the CISA-ADP containers, plus CWE and description +- CISA KEV membership, with the `knownRansomwareCampaignUse` string mapped explicitly to a real ransomware signal rather than treated as a boolean +- FIRST EPSS probability and percentile, parsed from the quoted strings the API actually returns so the score never silently reads as zero +- A TTL cache with a separate, shorter negative TTL, so a not-yet-published CVE is not re-fetched every run; NVD 2.0 is supported as an optional key-gated booster, never a requirement + +**Clustering and ranking** +- Connected-components (union-find) clustering: two items join when they share a CVE, or when they come from different outlets and their title token sets clear a Jaccard threshold inside a time window +- A pure, deterministic, news-first weighted score: recency, cross-outlet velocity, source trust, and a keyword watchlist carry 70 percent of the weight, with KEV, CVSS, and EPSS as the supporting 30, so the same corpus always sorts the same way and is pinned by golden-order tests + +**Surfaces** +- A colorful bubbletea terminal UI: a ranked list of dossiers with severity-reactive rows and KEV chips, a scrollable detail view with every outlet link and the full CVE card, and `o` to open a story in your browser +- A Markdown or JSON digest of the top-ranked clusters, for feeding a newsletter, a report, or another tool +- A single-CVE lookup that shows the enriched record and every stored story that mentions it + +**Content ideation, optional AI, off by default** +- Turn ranked clusters into summaries and content angles through one `Provider` interface: a local Qwen model via Ollama (keyless default), or Claude, OpenAI, or Gemini behind a single pasted key +- A re-runnable in-binary setup wizard writes keys to a `0600` credentials file behind a name allowlist, read from the environment and never logged + +**Watch daemon, optional** +- A long-lived scheduler that re-ingests on a timer and posts genuinely new, high-signal stories to Slack, Discord, or any JSON webhook +- New is measured on fetch time, not publish time, so a backfilled advisory fetched today still alerts exactly once; the daemon shuts down cleanly on Ctrl-C or SIGTERM and never crashes on a transient feed or network error + +## Quick Start + +```bash +curl -fsSL https://angelamos.com/nadezhda/install.sh | bash +``` + +One command, zero further steps: it grabs a prebuilt binary for your platform (no Go toolchain needed), drops it on your `PATH`, and leaves `nadezhda` runnable by name. Then pull the news and browse it: + +```bash +nadezhda scrape # pull every enabled feed, cluster, and enrich CVEs +nadezhda tui # browse the ranked dossier (? for keys, o opens a story) +nadezhda digest --top 20 # render a ranked Markdown digest (or --format json) +nadezhda cve CVE-2021-44228 # one enriched CVE and the stories that mention it +``` + +The default flow is `scrape` then `tui`; scrape already runs enrichment best-effort, so there is nothing else to wire up. A scrape prints a per-source table and a one-line summary: + +``` +SOURCE STATUS PARSED NEW DUP CVE ERR +krebs ok 10 3 7 1 0 +bleepingcomputer ok 18 6 12 4 0 +cisa 304 - - - - - +... +12 new, 45 duplicate, 8 CVE refs across 7 sources (0 failed) +132 clusters (14 multi-source, largest 5) +enriched 80/80 CVEs (14 KEV, 0 not found) +``` + +The optional layers are one command each: + +```bash +nadezhda ai # set up AI ideation: paste one key, or point at a local Ollama +nadezhda watch --interval 1h # run as a daemon, alerting new high-signal stories to a webhook +``` + +Prefer the Go toolchain? A real `go install github.com/CarterPerez-dev/nadezhda/cmd/nadezhda@latest` works too, and `just build` builds from a checkout. Building from source needs Go 1.25+, fetched automatically if you are on an older Go. + +> [!TIP] +> This project uses [`just`](https://github.com/casey/just) as a command runner. Type `just` to see every recipe. +> +> Install: `curl -sSf https://just.systems/install.sh | bash -s -- --to ~/.local/bin` + +## Learn + +This project ships a full teaching track. Read it in order, or jump to what you need. + +| Doc | What it covers | +|-----|----------------| +| [`learn/00-OVERVIEW.md`](learn/00-OVERVIEW.md) | What the tool is, prerequisites, the project layout, and a quick tour | +| [`learn/01-CONCEPTS.md`](learn/01-CONCEPTS.md) | The CVE intelligence stack, clustering as a velocity signal, and the ranking model, grounded in real incidents | +| [`learn/02-ARCHITECTURE.md`](learn/02-ARCHITECTURE.md) | The pipeline, the package map, the data model, and the design decisions | +| [`learn/03-IMPLEMENTATION.md`](learn/03-IMPLEMENTATION.md) | A code walkthrough from a feed item to a ranked, enriched cluster | +| [`learn/04-CHALLENGES.md`](learn/04-CHALLENGES.md) | Extension ideas, from adding a source to replacing the clustering with LSH | + +## Architecture + +One Go module, no service boundary, no message queue, and no external database. The `scrape` command runs the whole left-to-right flow once; the `watch` daemon runs it on a timer. Everything in `internal` exists to feed one function, `ingestAndCluster`, and everything downstream exists to rank and present what it produced. + +``` + sources.yaml (embedded default, or a user --config file) + │ + ▼ + ┌──────────────────────────────────────────────┐ + │ fetch N workers, per-host rate limit, │ internal/fetch + │ conditional GET (ETag / 304) │ + └───────────────────────┬──────────────────────┘ + │ raw feed bytes + ▼ + ┌──────────────────────────────────────────────┐ + │ parse → normalize → ingest │ parse / normalize / ingest + │ RSS/Atom, canonical URL, hash, fail-soft │ + └───────────────────────┬──────────────────────┘ + CVE regex │ union-find + ┌──────────┴──────────┐ + ▼ ▼ + ┌──────────────────────────────────────────────┐ + │ enrich CVE list / KEV / EPSS, cached, │ enrich / cve + │ keyless │ + └───────────────────────┬──────────────────────┘ + ▼ + ┌──────────────────────────────────────────────┐ + │ rank deterministic, news-first score │ internal/rank + └───────────────────────┬──────────────────────┘ + ┌────────────┼────────────┬───────────┐ + ▼ ▼ ▼ ▼ + digest tui ideate watch + (export) (browse) (AI) (daemon) +``` + +**Design decisions:** the store is `modernc.org/sqlite`, a pure-Go SQLite with no CGO, so the four-platform release binaries fall out of one build and the core needs no database server. Enrichment folds into `scrape` because the keyless CVE source is unthrottled, and it runs best-effort under a timeout so the news never blocks or fails on a slow CVE lookup. The `watch` daemon is a pure scheduler that imports nothing from the store or the pipeline; the concrete work is injected as a closure, so the loop, the graceful shutdown, and the fail-soft behavior are all unit-tested with a fake clock and no network. Alerts use a fetch-time watermark, not publish time, so an advisory published last week but fetched today is correctly new to you. + +## Build and Test + +```bash +just build # -> ./nadezhda (or: go build -o nadezhda ./cmd/nadezhda) +just test # go test ./... (18 packages) +just ollama-up # stand up the local Qwen runtime in Docker (optional AI) +``` + +Ranking is a pure function pinned to golden-order tests: fixed inputs produce one exact ordering. The keyless CVE client is pinned to a known-answer fixture, Log4Shell (CVE-2021-44228): the CVSS 10.0 score is read out of the CISA-ADP container because the vendor container holds only a placeholder, the weakness resolves to CWE-502, it is KEV-listed, and its EPSS score sits near the top of the scale. The `knownRansomwareCampaignUse` string mapping and the quoted-string EPSS parsing each have a regression test, because both are the quiet kind of bug that decodes wrong with no error. The watch scheduler is tested with a fake ticker a test drives by hand, so its behavior is verified with no clock, no network, and no database. + +## Project Structure + +``` +security-news-scraper/ +├── cmd/nadezhda/ # the CLI: one file per command + the shared pipeline seam +│ ├── scrape.go # the whole tool in miniature: runScrape +│ ├── pipeline.go # ingestAndCluster, the seam shared by scrape and watch +│ ├── tui.go # digest.go ideate.go watch.go cve.go list.go sources.go ai.go +│ └── main.go # root.go, the cobra command tree +├── internal/ +│ ├── fetch/ # concurrent, rate-limited, conditional HTTP (+ an unused robots gate) +│ ├── parse/ # RSS/Atom via gofeed, HTML fallback via goquery +│ ├── normalize/ # canonical URLs, content hashing, time parsing +│ ├── ingest/ # the fan-out orchestrator, fail-soft per source +│ ├── cluster/ # union-find clustering by title similarity and shared CVE +│ ├── cve/ # keyless clients: cvelistV5, CISA KEV, FIRST EPSS (+ optional NVD) +│ ├── enrich/ # enrichment orchestration and the TTL cache +│ ├── rank/ # the pure, deterministic weighted score +│ ├── store/ # SQLite: connection, migrations, and every typed query +│ ├── ai/ # the opt-in ideation layer, four providers behind one interface +│ ├── setup/ # the in-binary credential wizard +│ ├── watch/ # the daemon scheduler, decoupled from the work it runs +│ ├── tui/ # the bubbletea terminal browser +│ ├── export/ # the Markdown and JSON digest renderers +│ ├── source/ # the source registry and the embedded sources.yaml +│ ├── config/ # every tunable, with defaults and validation +│ └── version/ # the ldflags-injected version string +├── testdata/ # captured feed and API fixtures, driving the offline tests +├── install.sh # the one-shot curl-able installer +├── learn/ # the teaching track (public) +└── justfile # every recipe +``` + +## License + +[AGPL 3.0](LICENSE). diff --git a/PROJECTS/intermediate/security-news-scraper/assets/tui.png b/PROJECTS/intermediate/security-news-scraper/assets/tui.png new file mode 100644 index 00000000..fa3860ea Binary files /dev/null and b/PROJECTS/intermediate/security-news-scraper/assets/tui.png differ diff --git a/PROJECTS/intermediate/security-news-scraper/cmd/nadezhda/ai.go b/PROJECTS/intermediate/security-news-scraper/cmd/nadezhda/ai.go new file mode 100644 index 00000000..62beefcb --- /dev/null +++ b/PROJECTS/intermediate/security-news-scraper/cmd/nadezhda/ai.go @@ -0,0 +1,22 @@ +// ©AngelaMos | 2026 +// ai.go + +package main + +import ( + "github.com/spf13/cobra" + + "github.com/CarterPerez-dev/nadezhda/internal/setup" +) + +var aiCmd = &cobra.Command{ + Use: "ai", + Short: "Set up an AI provider for ideation (interactive, re-runnable)", + RunE: func(cmd *cobra.Command, args []string) error { + return setup.Run(cmd.InOrStdin(), cmd.OutOrStdout()) + }, +} + +func init() { + rootCmd.AddCommand(aiCmd) +} diff --git a/PROJECTS/intermediate/security-news-scraper/cmd/nadezhda/cve.go b/PROJECTS/intermediate/security-news-scraper/cmd/nadezhda/cve.go new file mode 100644 index 00000000..18ad9596 --- /dev/null +++ b/PROJECTS/intermediate/security-news-scraper/cmd/nadezhda/cve.go @@ -0,0 +1,105 @@ +// ©AngelaMos | 2026 +// cve.go + +package main + +import ( + "database/sql" + "errors" + "fmt" + "strings" + + "github.com/spf13/cobra" + + "github.com/CarterPerez-dev/nadezhda/internal/store" +) + +const naValue = "n/a" + +var cveCmd = &cobra.Command{ + Use: "cve CVE-YYYY-NNNN", + Short: "Show an enriched CVE and the articles mentioning it", + Args: cobra.ExactArgs(1), + RunE: runCVE, +} + +func init() { + rootCmd.AddCommand(cveCmd) +} + +func runCVE(cmd *cobra.Command, args []string) error { + cfg, err := loadConfig() + if err != nil { + return err + } + st, err := store.Open(cfg.DBPath) + if err != nil { + return err + } + defer st.Close() + + id := strings.ToUpper(args[0]) + c, err := st.GetCVE(id) + if err != nil { + if errors.Is(err, sql.ErrNoRows) { + return fmt.Errorf("%s not found; run 'nadezhda scrape' to discover it", id) + } + return err + } + + out := cmd.OutOrStdout() + fmt.Fprintf(out, "%s\n", c.ID) + if c.EnrichedAt == 0 { + fmt.Fprintln(out, " not enriched yet; run 'nadezhda enrich'") + } else { + fmt.Fprintf(out, " CVSS: %s\n", cvssLine(c)) + fmt.Fprintf(out, " CWE: %s\n", orNA(c.CWE)) + fmt.Fprintf(out, " KEV: %s\n", kevLine(c)) + fmt.Fprintf(out, " EPSS: %s\n", epssLine(c)) + if c.Description != "" { + fmt.Fprintf(out, "\n %s\n", c.Description) + } + } + + articles, err := st.ArticlesForCVE(id) + if err != nil { + return err + } + fmt.Fprintf(out, "\nMentioned in %d article(s):\n", len(articles)) + for _, a := range articles { + fmt.Fprintf(out, " [%s] %s\n %s\n", a.SourceName, a.Title, a.CanonicalURL) + } + return nil +} + +func cvssLine(c store.CVE) string { + if c.CVSSScore == nil { + return naValue + } + return fmt.Sprintf("%.1f %s (%s) %s", *c.CVSSScore, orNA(c.CVSSSeverity), orNA(c.CVSSVersion), c.CVSSVector) +} + +func kevLine(c store.CVE) string { + if !c.IsKEV { + return "no" + } + ransom := "no" + if c.KEVRansomware { + ransom = "yes" + } + return fmt.Sprintf("yes (added %s, ransomware: %s)", orNA(c.KEVDateAdded), ransom) +} + +func epssLine(c store.CVE) string { + if c.EPSS == nil || c.EPSSPercentile == nil { + return naValue + } + return fmt.Sprintf("%.5f (percentile %.5f)", *c.EPSS, *c.EPSSPercentile) +} + +func orNA(s string) string { + if s == "" { + return naValue + } + return s +} diff --git a/PROJECTS/intermediate/security-news-scraper/cmd/nadezhda/digest.go b/PROJECTS/intermediate/security-news-scraper/cmd/nadezhda/digest.go new file mode 100644 index 00000000..b4aed201 --- /dev/null +++ b/PROJECTS/intermediate/security-news-scraper/cmd/nadezhda/digest.go @@ -0,0 +1,101 @@ +// ©AngelaMos | 2026 +// digest.go + +package main + +import ( + "fmt" + "os" + "time" + + "github.com/spf13/cobra" + + "github.com/CarterPerez-dev/nadezhda/internal/export" + "github.com/CarterPerez-dev/nadezhda/internal/rank" + "github.com/CarterPerez-dev/nadezhda/internal/store" +) + +const ( + defaultDigestTop = 20 + formatMarkdown = "md" + formatJSON = "json" + outFilePerm = 0o644 +) + +var ( + digestTop int + digestSince string + digestFormat string + digestOut string +) + +var digestCmd = &cobra.Command{ + Use: "digest", + Short: "Render a ranked digest of story clusters to Markdown or JSON", + RunE: runDigest, +} + +func init() { + digestCmd.Flags().IntVar(&digestTop, "top", defaultDigestTop, "show the top N ranked clusters") + digestCmd.Flags().StringVar(&digestSince, "since", "", "only clusters active within this window (e.g. 24h, 168h)") + digestCmd.Flags().StringVar(&digestFormat, "format", formatMarkdown, "output format: md or json") + digestCmd.Flags().StringVar(&digestOut, "out", "", "write to this file instead of stdout") + rootCmd.AddCommand(digestCmd) +} + +func runDigest(cmd *cobra.Command, args []string) error { + cfg, err := loadConfig() + if err != nil { + return err + } + if digestFormat != formatMarkdown && digestFormat != formatJSON { + return fmt.Errorf("invalid --format %q: want md or json", digestFormat) + } + + var since int64 + now := time.Now() + if digestSince != "" { + d, err := time.ParseDuration(digestSince) + if err != nil { + return fmt.Errorf("invalid --since %q: %w", digestSince, err) + } + since = now.Add(-d).Unix() + } + + st, err := store.Open(cfg.DBPath) + if err != nil { + return err + } + defer st.Close() + + clusters, err := st.DigestClusters(since) + if err != nil { + return err + } + scored := rank.Rank(clusters, cfg.Rank, cfg.Watchlist, now) + + shown := len(scored) + if digestTop > 0 && digestTop < shown { + shown = digestTop + } + + var rendered string + if digestFormat == formatJSON { + rendered, err = export.JSON(scored, digestTop) + if err != nil { + return err + } + } else { + rendered = export.Markdown(scored, digestTop) + } + + if digestOut != "" { + if err := os.WriteFile(digestOut, []byte(rendered), outFilePerm); err != nil { + return fmt.Errorf("write digest to %s: %w", digestOut, err) + } + fmt.Fprintf(cmd.OutOrStdout(), "wrote %d clusters to %s\n", shown, digestOut) + return nil + } + fmt.Fprint(cmd.OutOrStdout(), rendered) + return nil +} diff --git a/PROJECTS/intermediate/security-news-scraper/cmd/nadezhda/enrich.go b/PROJECTS/intermediate/security-news-scraper/cmd/nadezhda/enrich.go new file mode 100644 index 00000000..27568097 --- /dev/null +++ b/PROJECTS/intermediate/security-news-scraper/cmd/nadezhda/enrich.go @@ -0,0 +1,76 @@ +// ©AngelaMos | 2026 +// enrich.go + +package main + +import ( + "fmt" + "net/http" + "os" + "time" + + "github.com/spf13/cobra" + + "github.com/CarterPerez-dev/nadezhda/internal/config" + "github.com/CarterPerez-dev/nadezhda/internal/cve" + "github.com/CarterPerez-dev/nadezhda/internal/enrich" + "github.com/CarterPerez-dev/nadezhda/internal/store" +) + +const nvdAPIKeyEnv = "NVD_API_KEY" + +var enrichCmd = &cobra.Command{ + Use: "enrich", + Short: "Refresh CVE intelligence (CVE List / NVD, CISA KEV, EPSS) for extracted CVEs", + Long: "Refresh CVE intelligence for extracted CVEs. Keyless by default (CVE Program, CISA KEV, EPSS); uses NVD only when NVD_API_KEY is set. scrape already runs this automatically, so this command is for manually refreshing.", + RunE: runEnrich, +} + +func init() { + rootCmd.AddCommand(enrichCmd) +} + +func runEnrich(cmd *cobra.Command, args []string) error { + cfg, err := loadConfig() + if err != nil { + return err + } + st, err := store.Open(cfg.DBPath) + if err != nil { + return err + } + defer st.Close() + + stats, err := enrich.Run(cmd.Context(), st, buildEnrichClients(cfg), time.Now(), cfg.Enrich.CacheTTLHours, cfg.Enrich.NegativeTTLHours) + if err != nil { + return err + } + + fmt.Fprintf(cmd.OutOrStdout(), + "enriched %d/%d CVEs (%d not found, %d KEV, %d errors)\n", + stats.Enriched, stats.Total, stats.NotFound, stats.KEVHits, stats.Errors) + return nil +} + +func buildEnrichClients(cfg config.Config) enrich.Clients { + httpClient := &http.Client{Timeout: time.Duration(cfg.Fetch.TimeoutSeconds) * time.Second} + return enrich.Clients{ + Core: buildCoreSource(httpClient, nvdAPIKey(cfg)), + KEV: cve.NewKEVClient(httpClient, cve.KEVEndpoint), + EPSS: cve.NewEPSSClient(httpClient, cve.EPSSEndpoint), + } +} + +func buildCoreSource(httpClient *http.Client, apiKey string) cve.CVESource { + if apiKey != "" { + return cve.NewNVDClient(httpClient, cve.NVDEndpoint, apiKey) + } + return cve.NewCVEListClient(httpClient, cve.CVEListEndpoint) +} + +func nvdAPIKey(cfg config.Config) string { + if k := os.Getenv(nvdAPIKeyEnv); k != "" { + return k + } + return cfg.Enrich.NVDAPIKey +} diff --git a/PROJECTS/intermediate/security-news-scraper/cmd/nadezhda/ideate.go b/PROJECTS/intermediate/security-news-scraper/cmd/nadezhda/ideate.go new file mode 100644 index 00000000..3bd6d329 --- /dev/null +++ b/PROJECTS/intermediate/security-news-scraper/cmd/nadezhda/ideate.go @@ -0,0 +1,181 @@ +// ©AngelaMos | 2026 +// ideate.go + +package main + +import ( + "encoding/json" + "errors" + "fmt" + "io" + "time" + + "github.com/spf13/cobra" + + "github.com/CarterPerez-dev/nadezhda/internal/ai" + "github.com/CarterPerez-dev/nadezhda/internal/rank" + "github.com/CarterPerez-dev/nadezhda/internal/setup" + "github.com/CarterPerez-dev/nadezhda/internal/store" +) + +const defaultIdeateTop = 10 + +var ( + ideateTop int + ideateSince string + ideateProvider string + ideateForce bool +) + +var ideateCmd = &cobra.Command{ + Use: "ideate", + Short: "Generate content angles from ranked clusters via an AI provider (opt-in)", + RunE: runIdeate, +} + +func init() { + ideateCmd.Flags().IntVar(&ideateTop, "top", defaultIdeateTop, "ideate the top N ranked clusters") + ideateCmd.Flags().StringVar(&ideateSince, "since", "", "only clusters active within this window (e.g. 24h, 168h)") + ideateCmd.Flags().StringVar(&ideateProvider, "provider", "", "override the configured provider: qwen|openai|anthropic|gemini") + ideateCmd.Flags().BoolVar(&ideateForce, "force", false, "re-ideate clusters that already have a note for this provider") + rootCmd.AddCommand(ideateCmd) +} + +func runIdeate(cmd *cobra.Command, args []string) error { + cfg, err := loadConfig() + if err != nil { + return err + } + + aiCfg := cfg.AI + if ideateProvider != "" { + aiCfg.Provider = ideateProvider + aiCfg.Enabled = true + } + if !aiCfg.Enabled { + if !isInteractive(cmd) { + return fmt.Errorf("AI is not set up — run `nadezhda ai` to configure a provider") + } + fmt.Fprintln(cmd.OutOrStdout(), "AI is not set up yet — let's fix that.") + if err := setup.Run(cmd.InOrStdin(), cmd.OutOrStdout()); err != nil { + return err + } + cfg, err = loadConfig() + if err != nil { + return err + } + aiCfg = cfg.AI + if !aiCfg.Enabled { + return fmt.Errorf("AI still not configured after setup") + } + if aiCfg.Provider == ai.ProviderQwen && !setup.OllamaReachable(aiCfg.Qwen.BaseURL) { + fmt.Fprintln(cmd.OutOrStdout(), "Ollama isn't reachable yet — finish the steps above, then run: nadezhda ideate") + return nil + } + } + provider, err := ai.Factory(aiCfg) + if err != nil { + return err + } + + now := time.Now() + var since int64 + if ideateSince != "" { + d, err := time.ParseDuration(ideateSince) + if err != nil { + return fmt.Errorf("invalid --since %q: %w", ideateSince, err) + } + since = now.Add(-d).Unix() + } + + st, err := store.Open(cfg.DBPath) + if err != nil { + return err + } + defer st.Close() + + clusters, err := st.DigestClusters(since) + if err != nil { + return err + } + scored := rank.Rank(clusters, cfg.Rank, cfg.Watchlist, now) + if ideateTop > 0 && ideateTop < len(scored) { + scored = scored[:ideateTop] + } + + out := cmd.OutOrStdout() + ctx := cmd.Context() + var generated, skipped, refused, failed int + + for _, s := range scored { + cid := s.Cluster.ClusterID + if !ideateForce { + exists, err := st.AINoteExists(cid, provider.Name()) + if err != nil { + return err + } + if exists { + skipped++ + fmt.Fprintf(out, "skip cluster %d (already ideated by %s; use --force)\n", cid, provider.Name()) + continue + } + } + + res, err := provider.Generate(ctx, ai.RequestFromCluster(s.Cluster)) + if err != nil { + if errors.Is(err, ai.ErrRefused) { + refused++ + fmt.Fprintf(out, "refused cluster %d (provider declined); skipping\n", cid) + } else { + failed++ + fmt.Fprintf(out, "warn cluster %d: %v\n", cid, err) + } + continue + } + + angles, err := json.Marshal(res.Angles) + if err != nil { + return err + } + note := store.AINote{ + ClusterID: cid, + Provider: provider.Name(), + Summary: res.Summary, + Why: res.Why, + AnglesJSON: string(angles), + Format: res.Format, + CreatedAt: time.Now().Unix(), + } + if err := st.InsertAINote(note); err != nil { + return err + } + generated++ + printIdeation(out, s, res) + } + + fmt.Fprintf(out, "\nideated %d, skipped %d, refused %d, failed %d (provider: %s)\n", generated, skipped, refused, failed, provider.Name()) + if generated == 0 && failed > 0 { + return fmt.Errorf("all %d ideation attempts failed", failed) + } + return nil +} + +func printIdeation(out io.Writer, s rank.Scored, res ai.IdeationResult) { + fmt.Fprintf(out, "\n=== cluster %d score %.2f [%s] ===\n", s.Cluster.ClusterID, s.Score, res.Format) + fmt.Fprintf(out, "%s\n\n", clusterHeadline(s.Cluster)) + fmt.Fprintf(out, "summary: %s\n\n", res.Summary) + fmt.Fprintf(out, "why: %s\n\n", res.Why) + fmt.Fprintln(out, "angles:") + for i, a := range res.Angles { + fmt.Fprintf(out, " %d. %s\n", i+1, a) + } +} + +func clusterHeadline(c store.DigestCluster) string { + for _, a := range c.Articles { + if a.Title != "" { + return a.Title + } + } + return "(untitled cluster)" +} diff --git a/PROJECTS/intermediate/security-news-scraper/cmd/nadezhda/ideate_test.go b/PROJECTS/intermediate/security-news-scraper/cmd/nadezhda/ideate_test.go new file mode 100644 index 00000000..e860e078 --- /dev/null +++ b/PROJECTS/intermediate/security-news-scraper/cmd/nadezhda/ideate_test.go @@ -0,0 +1,133 @@ +// ©AngelaMos | 2026 +// ideate_test.go + +package main + +import ( + "bytes" + "context" + "encoding/json" + "net/http" + "net/http/httptest" + "os" + "path/filepath" + "strings" + "testing" + + "github.com/spf13/cobra" + + "github.com/CarterPerez-dev/nadezhda/internal/setup" + "github.com/CarterPerez-dev/nadezhda/internal/store" +) + +func seedCluster(t *testing.T, st *store.Store) { + t.Helper() + stmts := []string{ + `INSERT INTO sources (id, name, url, type, weight, enabled) VALUES (1, 'krebs', 'https://krebsonsecurity.com', 'rss', 1.0, 1)`, + `INSERT INTO articles (id, source_id, canonical_url, content_hash, title, published_at) VALUES (1, 1, 'https://krebsonsecurity.com/a', 'h1', 'Critical RCE exploited in the wild', 1000)`, + `INSERT INTO clusters (id, cluster_key, first_seen, last_seen, size) VALUES (1, 'k1', 900, 1000, 1)`, + `INSERT INTO cluster_members (cluster_id, article_id) VALUES (1, 1)`, + } + for _, s := range stmts { + if _, err := st.DB().Exec(s); err != nil { + t.Fatalf("seed %q: %v", s, err) + } + } +} + +func TestIdeateCommandEndToEnd(t *testing.T) { + t.Setenv("XDG_CONFIG_HOME", t.TempDir()) + t.Setenv(setup.EnvProvider, "") + t.Setenv(setup.EnvQwenURL, "") + dir := t.TempDir() + dbPath := filepath.Join(dir, "test.db") + st, err := store.Open(dbPath) + if err != nil { + t.Fatalf("open store: %v", err) + } + seedCluster(t, st) + st.Close() + + srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + body, _ := json.Marshal(map[string]any{ + "choices": []map[string]any{{"message": map[string]any{ + "content": `{"summary":"a critical rce","why":"widely exploited","angles":["hook one","hook two","hook three"],"format":"newsletter"}`, + }}}, + }) + _, _ = w.Write(body) + })) + defer srv.Close() + + cfgPath := filepath.Join(dir, "config.yaml") + cfgYAML := "ai:\n enabled: true\n provider: qwen\n qwen:\n base_url: " + srv.URL + "\n model: qwen2.5:7b\n" + if err := os.WriteFile(cfgPath, []byte(cfgYAML), 0o644); err != nil { + t.Fatal(err) + } + + prevCfg, prevDB, prevTop, prevProv, prevForce, prevSince := flagConfig, flagDB, ideateTop, ideateProvider, ideateForce, ideateSince + defer func() { + flagConfig, flagDB, ideateTop, ideateProvider, ideateForce, ideateSince = prevCfg, prevDB, prevTop, prevProv, prevForce, prevSince + }() + flagConfig, flagDB, ideateTop, ideateProvider, ideateForce, ideateSince = cfgPath, dbPath, 1, "", false, "" + + cmd := &cobra.Command{} + cmd.SetContext(context.Background()) + var buf bytes.Buffer + cmd.SetOut(&buf) + + if err := runIdeate(cmd, nil); err != nil { + t.Fatalf("runIdeate: %v\noutput:\n%s", err, buf.String()) + } + out := buf.String() + for _, want := range []string{"ideated 1", "a critical rce", "hook one", "newsletter"} { + if !strings.Contains(out, want) { + t.Errorf("ideate output missing %q\n---\n%s", want, out) + } + } + + st2, err := store.Open(dbPath) + if err != nil { + t.Fatal(err) + } + ok, err := st2.AINoteExists(1, "qwen") + st2.Close() + if err != nil || !ok { + t.Fatalf("note not persisted: ok=%v err=%v", ok, err) + } + + buf.Reset() + if err := runIdeate(cmd, nil); err != nil { + t.Fatalf("second runIdeate: %v", err) + } + if !strings.Contains(buf.String(), "skip cluster 1") { + t.Errorf("second run should skip existing note:\n%s", buf.String()) + } + + buf.Reset() + ideateForce = true + if err := runIdeate(cmd, nil); err != nil { + t.Fatalf("force runIdeate: %v", err) + } + if !strings.Contains(buf.String(), "ideated 1") { + t.Errorf("--force should regenerate, not skip:\n%s", buf.String()) + } +} + +func TestIdeateDisabledErrors(t *testing.T) { + t.Setenv("XDG_CONFIG_HOME", t.TempDir()) + t.Setenv(setup.EnvProvider, "") + t.Setenv(setup.EnvQwenURL, "") + prevCfg, prevProv := flagConfig, ideateProvider + defer func() { flagConfig, ideateProvider = prevCfg, prevProv }() + flagConfig, ideateProvider = "", "" + + cmd := &cobra.Command{} + cmd.SetContext(context.Background()) + cmd.SetOut(&bytes.Buffer{}) + cmd.SetIn(strings.NewReader("")) + + err := runIdeate(cmd, nil) + if err == nil || !strings.Contains(err.Error(), "not set up") { + t.Fatalf("expected a 'not set up' error, got %v", err) + } +} diff --git a/PROJECTS/intermediate/security-news-scraper/cmd/nadezhda/list.go b/PROJECTS/intermediate/security-news-scraper/cmd/nadezhda/list.go new file mode 100644 index 00000000..ac91f619 --- /dev/null +++ b/PROJECTS/intermediate/security-news-scraper/cmd/nadezhda/list.go @@ -0,0 +1,92 @@ +// ©AngelaMos | 2026 +// list.go + +package main + +import ( + "fmt" + "time" + + "github.com/spf13/cobra" + + "github.com/CarterPerez-dev/nadezhda/internal/store" +) + +const ( + defaultListLimit = 50 + dateLayout = "2006-01-02" + noDate = "----------" +) + +var ( + listSource string + listSince string + listMinCVSS float64 + listKEV bool + listKeyword string + listLimit int +) + +var listCmd = &cobra.Command{ + Use: "list", + Short: "List stored articles with filters", + RunE: runList, +} + +func init() { + listCmd.Flags().StringVar(&listSource, "source", "", "filter by source name") + listCmd.Flags().StringVar(&listSince, "since", "", "only articles published within this window (e.g. 24h, 168h)") + listCmd.Flags().Float64Var(&listMinCVSS, "min-cvss", 0, "only articles referencing a CVE with CVSS >= this") + listCmd.Flags().BoolVar(&listKEV, "kev", false, "only articles referencing a KEV-listed CVE") + listCmd.Flags().StringVar(&listKeyword, "keyword", "", "filter by keyword in title or summary") + listCmd.Flags().IntVar(&listLimit, "limit", defaultListLimit, "maximum rows to show") + rootCmd.AddCommand(listCmd) +} + +func runList(cmd *cobra.Command, args []string) error { + cfg, err := loadConfig() + if err != nil { + return err + } + + filter := store.ListFilter{ + Source: listSource, + MinCVSS: listMinCVSS, + KEV: listKEV, + Keyword: listKeyword, + Limit: listLimit, + } + if listSince != "" { + d, err := time.ParseDuration(listSince) + if err != nil { + return fmt.Errorf("invalid --since %q: %w", listSince, err) + } + filter.Since = time.Now().Add(-d).Unix() + } + + st, err := store.Open(cfg.DBPath) + if err != nil { + return err + } + defer st.Close() + + articles, err := st.ListArticles(filter) + if err != nil { + return err + } + + out := cmd.OutOrStdout() + fmt.Fprintf(out, "%-10s %-16s %s\n", "DATE", "SOURCE", "TITLE") + for _, a := range articles { + fmt.Fprintf(out, "%-10s %-16s %s\n", formatDate(a.PublishedAt), a.SourceName, a.Title) + } + fmt.Fprintf(out, "\n%d article(s)\n", len(articles)) + return nil +} + +func formatDate(unix int64) string { + if unix == 0 { + return noDate + } + return time.Unix(unix, 0).UTC().Format(dateLayout) +} diff --git a/PROJECTS/intermediate/security-news-scraper/cmd/nadezhda/main.go b/PROJECTS/intermediate/security-news-scraper/cmd/nadezhda/main.go new file mode 100644 index 00000000..63e5bdcc --- /dev/null +++ b/PROJECTS/intermediate/security-news-scraper/cmd/nadezhda/main.go @@ -0,0 +1,19 @@ +// ©AngelaMos | 2026 +// main.go + +package main + +import ( + "context" + "os" + "os/signal" + "syscall" +) + +func main() { + ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM) + defer stop() + if err := rootCmd.ExecuteContext(ctx); err != nil { + os.Exit(1) + } +} diff --git a/PROJECTS/intermediate/security-news-scraper/cmd/nadezhda/pipeline.go b/PROJECTS/intermediate/security-news-scraper/cmd/nadezhda/pipeline.go new file mode 100644 index 00000000..bd8bdea3 --- /dev/null +++ b/PROJECTS/intermediate/security-news-scraper/cmd/nadezhda/pipeline.go @@ -0,0 +1,30 @@ +// ©AngelaMos | 2026 +// pipeline.go + +package main + +import ( + "context" + "time" + + "github.com/CarterPerez-dev/nadezhda/internal/cluster" + "github.com/CarterPerez-dev/nadezhda/internal/config" + "github.com/CarterPerez-dev/nadezhda/internal/fetch" + "github.com/CarterPerez-dev/nadezhda/internal/ingest" + "github.com/CarterPerez-dev/nadezhda/internal/source" + "github.com/CarterPerez-dev/nadezhda/internal/store" +) + +func ingestAndCluster(ctx context.Context, fc *fetch.Client, st *store.Store, cfg config.Config, targets []source.Source, start time.Time) (ingest.Summary, cluster.Stats, error) { + summary, err := ingest.Run(ctx, fc, st, cfg, targets, start) + if err != nil { + return ingest.Summary{}, cluster.Stats{}, err + } + sinceUnix := start.Unix() - int64(cfg.Cluster.LookbackHours)*secondsPerHour + windowSeconds := int64(cfg.Cluster.WindowHours) * secondsPerHour + stats, err := cluster.Rebuild(st, cfg.Cluster.TitleJaccard, windowSeconds, sinceUnix) + if err != nil { + return summary, cluster.Stats{}, err + } + return summary, stats, nil +} diff --git a/PROJECTS/intermediate/security-news-scraper/cmd/nadezhda/root.go b/PROJECTS/intermediate/security-news-scraper/cmd/nadezhda/root.go new file mode 100644 index 00000000..25b7ea95 --- /dev/null +++ b/PROJECTS/intermediate/security-news-scraper/cmd/nadezhda/root.go @@ -0,0 +1,60 @@ +// ©AngelaMos | 2026 +// root.go + +package main + +import ( + "os" + + "github.com/spf13/cobra" + + "github.com/CarterPerez-dev/nadezhda/internal/config" + "github.com/CarterPerez-dev/nadezhda/internal/setup" +) + +var ( + flagConfig string + flagDB string +) + +var rootCmd = &cobra.Command{ + Use: "nadezhda", + Short: "Security news and CVE aggregation engine", + Long: "Nadezhda aggregates cybersecurity news, enriches CVEs with NVD, CISA KEV, and EPSS intelligence, clusters stories across outlets, and ranks what matters.", + SilenceUsage: true, +} + +func init() { + rootCmd.PersistentFlags().StringVar(&flagConfig, "config", "", "path to config.yaml (optional)") + rootCmd.PersistentFlags().StringVar(&flagDB, "db", "", "override database path") +} + +func loadConfig() (config.Config, error) { + if err := setup.Load(); err != nil { + return config.Config{}, err + } + cfg, err := config.Load(flagConfig) + if err != nil { + return config.Config{}, err + } + if flagDB != "" { + cfg.DBPath = flagDB + } + if p := os.Getenv(setup.EnvProvider); p != "" { + cfg.AI.Enabled = true + cfg.AI.Provider = p + } + if u := os.Getenv(setup.EnvQwenURL); u != "" { + cfg.AI.Qwen.BaseURL = u + } + return cfg, nil +} + +func isInteractive(cmd *cobra.Command) bool { + f, ok := cmd.InOrStdin().(*os.File) + if !ok { + return false + } + fi, err := f.Stat() + return err == nil && fi.Mode()&os.ModeCharDevice != 0 +} diff --git a/PROJECTS/intermediate/security-news-scraper/cmd/nadezhda/scrape.go b/PROJECTS/intermediate/security-news-scraper/cmd/nadezhda/scrape.go new file mode 100644 index 00000000..e89da4e0 --- /dev/null +++ b/PROJECTS/intermediate/security-news-scraper/cmd/nadezhda/scrape.go @@ -0,0 +1,162 @@ +// ©AngelaMos | 2026 +// scrape.go + +package main + +import ( + "context" + "fmt" + "time" + + "github.com/spf13/cobra" + + "github.com/CarterPerez-dev/nadezhda/internal/config" + "github.com/CarterPerez-dev/nadezhda/internal/enrich" + "github.com/CarterPerez-dev/nadezhda/internal/fetch" + "github.com/CarterPerez-dev/nadezhda/internal/ingest" + "github.com/CarterPerez-dev/nadezhda/internal/source" + "github.com/CarterPerez-dev/nadezhda/internal/store" +) + +const secondsPerHour = 3600 + +const enrichBudget = 5 * time.Minute + +const ( + statusNotModified = "304" + statusError = "error" + statusOK = "ok" + dash = "-" +) + +var ( + scrapeSource string + scrapeNoEnrich bool +) + +var scrapeCmd = &cobra.Command{ + Use: "scrape", + Short: "Ingest all enabled sources once", + RunE: runScrape, +} + +func init() { + scrapeCmd.Flags().StringVar(&scrapeSource, "source", "", "ingest only this source by name") + scrapeCmd.Flags().BoolVar(&scrapeNoEnrich, "no-enrich", false, "skip the keyless CVE enrichment pass") + rootCmd.AddCommand(scrapeCmd) +} + +func runScrape(cmd *cobra.Command, args []string) error { + cfg, err := loadConfig() + if err != nil { + return err + } + srcs, err := source.Load(cfg.SourcesPath) + if err != nil { + return err + } + + targets, err := selectTargets(srcs, scrapeSource) + if err != nil { + return err + } + + st, err := store.Open(cfg.DBPath) + if err != nil { + return err + } + defer st.Close() + + fc := fetch.New(fetch.Options{ + UserAgent: cfg.Fetch.UserAgent, + PerHostRate: cfg.Fetch.PerHostRate, + PerHostBurst: cfg.Fetch.PerHostBurst, + Timeout: time.Duration(cfg.Fetch.TimeoutSeconds) * time.Second, + MaxRetries: cfg.Fetch.MaxRetries, + }) + + ctx := cmd.Context() + now := time.Now() + summary, cstats, err := ingestAndCluster(ctx, fc, st, cfg, targets, now) + if err != nil { + return err + } + printSummary(cmd, summary) + fmt.Fprintf(cmd.OutOrStdout(), "%d clusters (%d multi-source, largest %d)\n", + cstats.Total, cstats.MultiSource, cstats.LargestSize) + + if !scrapeNoEnrich { + enrichAfterScrape(ctx, cmd, cfg, st) + } + return nil +} + +func enrichAfterScrape(ctx context.Context, cmd *cobra.Command, cfg config.Config, st *store.Store) { + out := cmd.OutOrStdout() + ectx, cancel := context.WithTimeout(ctx, enrichBudget) + defer cancel() + + stats, err := enrich.Run(ectx, st, buildEnrichClients(cfg), time.Now(), cfg.Enrich.CacheTTLHours, cfg.Enrich.NegativeTTLHours) + if err != nil { + if done := stats.Enriched + stats.NotFound; done > 0 { + fmt.Fprintf(out, "enriched %d/%d CVEs before stopping: %v\n", done, stats.Total, err) + } else { + fmt.Fprintf(out, "enrich skipped: %v (news is unaffected)\n", err) + } + return + } + if stats.Total == 0 { + return + } + fmt.Fprintf(out, "enriched %d/%d CVEs (%d KEV, %d not found)\n", + stats.Enriched, stats.Total, stats.KEVHits, stats.NotFound) +} + +func selectTargets(srcs []source.Source, only string) ([]source.Source, error) { + if only != "" { + for _, s := range srcs { + if s.Name == only { + return []source.Source{s}, nil + } + } + return nil, fmt.Errorf("scrape: unknown source %q", only) + } + return source.Enabled(srcs), nil +} + +func printSummary(cmd *cobra.Command, summary ingest.Summary) { + out := cmd.OutOrStdout() + fmt.Fprintf(out, "%-18s %-8s %-8s %-5s %-5s %-5s %-5s\n", "SOURCE", "STATUS", "PARSED", "NEW", "DUP", "CVE", "ERR") + totalCVEs := 0 + for _, r := range summary.Results { + totalCVEs += r.CVEs + fmt.Fprintf(out, "%-18s %-8s %-8s %-5s %-5s %-5s %-5s\n", + r.Name, status(r), count(r, r.Parsed), count(r, r.New), count(r, r.Duplicates), count(r, r.CVEs), count(r, r.ItemErrors)) + } + newArticles, duplicates, failed := summary.Totals() + fmt.Fprintf(out, "\n%d new, %d duplicate, %d CVE refs across %d sources (%d failed)\n", + newArticles, duplicates, totalCVEs, len(summary.Results), failed) + for _, r := range summary.Results { + if r.Err != nil { + fmt.Fprintf(out, " %s: %v\n", r.Name, r.Err) + } + } +} + +func status(r ingest.SourceResult) string { + switch { + case r.Err != nil: + return statusError + case r.NotModified: + return statusNotModified + default: + return statusOK + } +} + +func count(r ingest.SourceResult, n int) string { + if r.Err != nil || r.NotModified { + return dash + } + return fmt.Sprintf("%d", n) +} diff --git a/PROJECTS/intermediate/security-news-scraper/cmd/nadezhda/sources.go b/PROJECTS/intermediate/security-news-scraper/cmd/nadezhda/sources.go new file mode 100644 index 00000000..0c902d8f --- /dev/null +++ b/PROJECTS/intermediate/security-news-scraper/cmd/nadezhda/sources.go @@ -0,0 +1,60 @@ +// ©AngelaMos | 2026 +// sources.go + +package main + +import ( + "fmt" + + "github.com/spf13/cobra" + + "github.com/CarterPerez-dev/nadezhda/internal/source" + "github.com/CarterPerez-dev/nadezhda/internal/store" +) + +var sourcesCmd = &cobra.Command{ + Use: "sources", + Short: "List configured sources and persist them to the store", + RunE: runSources, +} + +func init() { + rootCmd.AddCommand(sourcesCmd) +} + +func runSources(cmd *cobra.Command, args []string) error { + cfg, err := loadConfig() + if err != nil { + return err + } + srcs, err := source.Load(cfg.SourcesPath) + if err != nil { + return err + } + st, err := store.Open(cfg.DBPath) + if err != nil { + return err + } + defer st.Close() + + for _, s := range srcs { + if _, err := st.UpsertSource(store.SourceInput{ + Name: s.Name, Title: s.Title, URL: s.URL, Type: string(s.Type), + Weight: s.Weight, Tags: s.Tags, Enabled: s.Enabled, + }); err != nil { + return err + } + } + + fmt.Printf("%-18s %-8s %-7s %s\n", "NAME", "ENABLED", "WEIGHT", "URL") + for _, s := range srcs { + enabled := "no" + if s.Enabled { + enabled = "yes" + } + fmt.Printf("%-18s %-8s %-7.2f %s\n", s.Name, enabled, s.Weight, s.URL) + } + fmt.Printf("\n%d sources (%d enabled) persisted to %s\n", + len(srcs), len(source.Enabled(srcs)), cfg.DBPath) + return nil +} diff --git a/PROJECTS/intermediate/security-news-scraper/cmd/nadezhda/tui.go b/PROJECTS/intermediate/security-news-scraper/cmd/nadezhda/tui.go new file mode 100644 index 00000000..5135e0bd --- /dev/null +++ b/PROJECTS/intermediate/security-news-scraper/cmd/nadezhda/tui.go @@ -0,0 +1,117 @@ +// ©AngelaMos | 2026 +// tui.go + +package main + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/spf13/cobra" + + "github.com/CarterPerez-dev/nadezhda/internal/ai" + "github.com/CarterPerez-dev/nadezhda/internal/rank" + "github.com/CarterPerez-dev/nadezhda/internal/store" + "github.com/CarterPerez-dev/nadezhda/internal/tui" +) + +var tuiSince string + +var tuiCmd = &cobra.Command{ + Use: "tui", + Short: "Browse aggregated news in an interactive terminal UI", + RunE: runTUI, +} + +func init() { + tuiCmd.Flags().StringVar(&tuiSince, "since", "", "only clusters active within this window (e.g. 24h, 168h)") + rootCmd.AddCommand(tuiCmd) +} + +func runTUI(cmd *cobra.Command, args []string) error { + cfg, err := loadConfig() + if err != nil { + return err + } + + now := time.Now() + var since int64 + if tuiSince != "" { + d, err := time.ParseDuration(tuiSince) + if err != nil { + return fmt.Errorf("invalid --since %q: %w", tuiSince, err) + } + since = now.Add(-d).Unix() + } + + st, err := store.Open(cfg.DBPath) + if err != nil { + return err + } + defer st.Close() + + loader := func() (tui.Data, error) { + clusters, err := st.DigestClusters(since) + if err != nil { + return tui.Data{}, err + } + scored := rank.Rank(clusters, cfg.Rank, cfg.Watchlist, now) + detail := make(map[string]store.CVE) + for _, s := range scored { + for _, v := range s.Cluster.CVEs { + if _, ok := detail[v.ID]; ok { + continue + } + full, err := st.GetCVE(v.ID) + if err != nil { + continue + } + detail[v.ID] = full + } + } + notes := map[int64]ai.IdeationResult{} + if persisted, err := st.LatestAINotes(); err == nil { + for cid, n := range persisted { + var angles []string + _ = json.Unmarshal([]byte(n.AnglesJSON), &angles) + notes[cid] = ai.IdeationResult{Summary: n.Summary, Why: n.Why, Angles: angles, Format: n.Format} + } + } + return tui.Data{Scored: scored, CVEDetail: detail, Notes: notes}, nil + } + + var ideator tui.Ideator + if cfg.AI.Enabled { + provider, err := ai.Factory(cfg.AI) + if err != nil { + return err + } + ctx := cmd.Context() + ideator = func(c store.DigestCluster) (ai.IdeationResult, error) { + res, err := provider.Generate(ctx, ai.RequestFromCluster(c)) + if err != nil { + return ai.IdeationResult{}, err + } + angles, err := json.Marshal(res.Angles) + if err != nil { + return ai.IdeationResult{}, err + } + note := store.AINote{ + ClusterID: c.ClusterID, + Provider: provider.Name(), + Summary: res.Summary, + Why: res.Why, + AnglesJSON: string(angles), + Format: res.Format, + CreatedAt: time.Now().Unix(), + } + if err := st.InsertAINote(note); err != nil { + return ai.IdeationResult{}, fmt.Errorf("save note: %w", err) + } + return res, nil + } + } + + return tui.Run(loader, ideator) +} diff --git a/PROJECTS/intermediate/security-news-scraper/cmd/nadezhda/version.go b/PROJECTS/intermediate/security-news-scraper/cmd/nadezhda/version.go new file mode 100644 index 00000000..7192b63e --- /dev/null +++ b/PROJECTS/intermediate/security-news-scraper/cmd/nadezhda/version.go @@ -0,0 +1,25 @@ +// ©AngelaMos | 2026 +// version.go + +package main + +import ( + "fmt" + + "github.com/spf13/cobra" + + "github.com/CarterPerez-dev/nadezhda/internal/version" +) + +var versionCmd = &cobra.Command{ + Use: "version", + Short: "Print version", + RunE: func(cmd *cobra.Command, args []string) error { + fmt.Printf("%s %s\n", version.Name, version.Version) + return nil + }, +} + +func init() { + rootCmd.AddCommand(versionCmd) +} diff --git a/PROJECTS/intermediate/security-news-scraper/cmd/nadezhda/watch.go b/PROJECTS/intermediate/security-news-scraper/cmd/nadezhda/watch.go new file mode 100644 index 00000000..52f63d60 --- /dev/null +++ b/PROJECTS/intermediate/security-news-scraper/cmd/nadezhda/watch.go @@ -0,0 +1,258 @@ +// ©AngelaMos | 2026 +// watch.go + +package main + +import ( + "context" + "fmt" + "io" + "net/http" + "net/url" + "time" + + "github.com/spf13/cobra" + + "github.com/CarterPerez-dev/nadezhda/internal/config" + "github.com/CarterPerez-dev/nadezhda/internal/enrich" + "github.com/CarterPerez-dev/nadezhda/internal/fetch" + "github.com/CarterPerez-dev/nadezhda/internal/rank" + "github.com/CarterPerez-dev/nadezhda/internal/source" + "github.com/CarterPerez-dev/nadezhda/internal/store" + "github.com/CarterPerez-dev/nadezhda/internal/watch" +) + +const untitledCluster = "(untitled cluster)" + +var ( + watchInterval string + watchOnce bool + watchNoEnrich bool +) + +var watchCmd = &cobra.Command{ + Use: "watch", + Short: "Run as a daemon, re-ingesting on an interval with an optional webhook notify", + Long: "Run nadezhda as a long-lived daemon that re-ingests every enabled source on an interval " + + "(default from config, override with --interval). Each cycle scrapes, clusters, and enriches " + + "exactly like the scrape command. When watch.webhook_url is set, genuinely new high-signal " + + "stories are POSTed to that webhook (Slack, Discord, or any JSON endpoint).", + RunE: runWatch, +} + +func init() { + watchCmd.Flags().StringVar(&watchInterval, "interval", "", "re-ingest interval, e.g. 30m or 1h (overrides watch.interval in config)") + watchCmd.Flags().BoolVar(&watchOnce, "once", false, "run a single cycle and exit instead of looping") + watchCmd.Flags().BoolVar(&watchNoEnrich, "no-enrich", false, "skip the keyless CVE enrichment pass each cycle") + rootCmd.AddCommand(watchCmd) +} + +func runWatch(cmd *cobra.Command, args []string) error { + cfg, err := loadConfig() + if err != nil { + return err + } + interval, err := resolveWatchInterval(cfg) + if err != nil { + return err + } + if cfg.Watch.WebhookURL != "" { + if err := validateWebhookURL(cfg.Watch.WebhookURL); err != nil { + return err + } + } + + srcs, err := source.Load(cfg.SourcesPath) + if err != nil { + return err + } + targets := source.Enabled(srcs) + if len(targets) == 0 { + return fmt.Errorf("watch: no enabled sources to poll") + } + + st, err := store.Open(cfg.DBPath) + if err != nil { + return err + } + defer st.Close() + + fc := fetch.New(fetch.Options{ + UserAgent: cfg.Fetch.UserAgent, + PerHostRate: cfg.Fetch.PerHostRate, + PerHostBurst: cfg.Fetch.PerHostBurst, + Timeout: time.Duration(cfg.Fetch.TimeoutSeconds) * time.Second, + MaxRetries: cfg.Fetch.MaxRetries, + }) + + out := cmd.ErrOrStderr() + if watchNoEnrich && cfg.Watch.NotifyOnKEV { + fmt.Fprintln(out, "watch: --no-enrich with notify_on_kev set: KEV status is never computed, so KEV alerts will not fire") + } + + cycle := func(ctx context.Context) (watch.Report, error) { + start := time.Now() + summary, cstats, err := ingestAndCluster(ctx, fc, st, cfg, targets, start) + if err != nil { + return watch.Report{}, err + } + newArticles, duplicates, failed := summary.Totals() + + var enriched, kevHits int + if !watchNoEnrich { + enriched, kevHits = watchEnrich(ctx, out, st, cfg) + } + + notable, err := buildNotable(st, cfg, start) + if err != nil { + return watch.Report{}, err + } + return watch.Report{ + Start: start, + Duration: time.Since(start), + NewArticles: newArticles, + Duplicates: duplicates, + Clusters: cstats.Total, + Enriched: enriched, + KEVHits: kevHits, + Failed: failed, + Notable: notable, + }, nil + } + + opts := watch.Options{ + Interval: interval, + RunAtStart: true, + Cycle: cycle, + Out: out, + } + if cfg.Watch.WebhookURL != "" { + opts.Notifier = watch.WebhookNotifier{ + URL: cfg.Watch.WebhookURL, + Client: &http.Client{Timeout: time.Duration(cfg.Fetch.TimeoutSeconds) * time.Second}, + } + } + + if watchOnce { + return watch.Once(cmd.Context(), opts) + } + return watch.Run(cmd.Context(), opts) +} + +func resolveWatchInterval(cfg config.Config) (time.Duration, error) { + raw := cfg.Watch.Interval + if watchInterval != "" { + raw = watchInterval + } + d, err := time.ParseDuration(raw) + if err != nil { + return 0, fmt.Errorf("watch: invalid interval %q: %w", raw, err) + } + if d < config.MinWatchInterval { + return 0, fmt.Errorf("watch: interval %s is below the minimum %s", d, config.MinWatchInterval) + } + return d, nil +} + +func validateWebhookURL(raw string) error { + u, err := url.Parse(raw) + if err != nil { + return fmt.Errorf("watch: invalid webhook_url %q: %w", raw, err) + } + if u.Scheme != "http" && u.Scheme != "https" { + return fmt.Errorf("watch: webhook_url must be http or https, got %q", raw) + } + if u.Host == "" { + return fmt.Errorf("watch: webhook_url must include a host, got %q", raw) + } + return nil +} + +func watchEnrich(ctx context.Context, out io.Writer, st *store.Store, cfg config.Config) (enriched, kevHits int) { + ectx, cancel := context.WithTimeout(ctx, enrichBudget) + defer cancel() + stats, err := enrich.Run(ectx, st, buildEnrichClients(cfg), time.Now(), cfg.Enrich.CacheTTLHours, cfg.Enrich.NegativeTTLHours) + if err != nil && ctx.Err() == nil { + fmt.Fprintf(out, "watch: enrich degraded, KEV/CVE data may be stale: %v\n", err) + } + return stats.Enriched, stats.KEVHits +} + +func buildNotable(st *store.Store, cfg config.Config, cycleStart time.Time) ([]watch.NotableItem, error) { + fresh, err := st.NewlyFetchedClusters(cycleStart.Unix()) + if err != nil { + return nil, err + } + scored := rank.Rank(fresh, cfg.Rank, cfg.Watchlist, time.Now()) + items := make([]watch.NotableItem, 0, cfg.Watch.NotifyMaxItems) + for _, sc := range scored { + if len(items) >= cfg.Watch.NotifyMaxItems { + break + } + if isNotable(sc, cfg.Watch) { + items = append(items, toNotable(sc)) + } + } + return items, nil +} + +func isNotable(sc rank.Scored, w config.Watch) bool { + if sc.Score >= w.NotifyMinScore { + return true + } + if w.NotifyOnKEV { + for _, v := range sc.Cluster.CVEs { + if v.IsKEV { + return true + } + } + } + return false +} + +func toNotable(sc rank.Scored) watch.NotableItem { + c := sc.Cluster + title, link := representativeArticle(c.Articles) + var maxCVSS float64 + var isKEV bool + cves := make([]string, 0, len(c.CVEs)) + for _, v := range c.CVEs { + cves = append(cves, v.ID) + if v.CVSSScore != nil && *v.CVSSScore > maxCVSS { + maxCVSS = *v.CVSSScore + } + if v.IsKEV { + isKEV = true + } + } + return watch.NotableItem{ + Title: title, + URL: link, + Score: sc.Score, + MaxCVSS: maxCVSS, + IsKEV: isKEV, + CVEs: cves, + Sources: distinctSources(c.Articles), + } +} + +func representativeArticle(articles []store.DigestArticle) (title, link string) { + if len(articles) == 0 { + return untitledCluster, "" + } + best := articles[0] + for _, a := range articles[1:] { + if a.SourceWeight > best.SourceWeight { + best = a + } + } + return best.Title, best.CanonicalURL +} + +func distinctSources(articles []store.DigestArticle) int { + set := make(map[string]struct{}, len(articles)) + for _, a := range articles { + set[a.SourceName] = struct{}{} + } + return len(set) +} diff --git a/PROJECTS/intermediate/security-news-scraper/cmd/nadezhda/watch_test.go b/PROJECTS/intermediate/security-news-scraper/cmd/nadezhda/watch_test.go new file mode 100644 index 00000000..cfd88fa5 --- /dev/null +++ b/PROJECTS/intermediate/security-news-scraper/cmd/nadezhda/watch_test.go @@ -0,0 +1,149 @@ +// ©AngelaMos | 2026 +// watch_test.go + +package main + +import ( + "fmt" + "path/filepath" + "strconv" + "testing" + "time" + + "github.com/CarterPerez-dev/nadezhda/internal/config" + "github.com/CarterPerez-dev/nadezhda/internal/rank" + "github.com/CarterPerez-dev/nadezhda/internal/store" +) + +func TestIsNotable(t *testing.T) { + kevCluster := store.DigestCluster{CVEs: []store.DigestCVE{{ID: "CVE-2026-1", IsKEV: true}}} + plainCluster := store.DigestCluster{} + tests := []struct { + name string + scored rank.Scored + watch config.Watch + want bool + }{ + {"score above threshold", rank.Scored{Cluster: plainCluster, Score: 0.9}, config.Watch{NotifyMinScore: 0.5}, true}, + {"score below threshold, not kev", rank.Scored{Cluster: plainCluster, Score: 0.2}, config.Watch{NotifyMinScore: 0.5}, false}, + {"below threshold but kev with notify_on_kev", rank.Scored{Cluster: kevCluster, Score: 0.1}, config.Watch{NotifyMinScore: 0.5, NotifyOnKEV: true}, true}, + {"kev but notify_on_kev off", rank.Scored{Cluster: kevCluster, Score: 0.1}, config.Watch{NotifyMinScore: 0.5, NotifyOnKEV: false}, false}, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := isNotable(tt.scored, tt.watch); got != tt.want { + t.Errorf("isNotable = %v, want %v", got, tt.want) + } + }) + } +} + +func TestToNotablePicksHighestAuthoritySource(t *testing.T) { + cvss := 9.8 + sc := rank.Scored{ + Score: 0.77, + Cluster: store.DigestCluster{ + Articles: []store.DigestArticle{ + {Title: "low authority", CanonicalURL: "https://low", SourceName: "low", SourceWeight: 0.5}, + {Title: "high authority", CanonicalURL: "https://high", SourceName: "high", SourceWeight: 1.0}, + }, + CVEs: []store.DigestCVE{{ID: "CVE-2026-1", CVSSScore: &cvss, IsKEV: true}}, + }, + } + n := toNotable(sc) + if n.Title != "high authority" || n.URL != "https://high" { + t.Errorf("representative should be the highest-source-weight article, got %q / %q", n.Title, n.URL) + } + if !n.IsKEV || n.MaxCVSS != 9.8 { + t.Errorf("cve signals wrong: kev=%v cvss=%v", n.IsKEV, n.MaxCVSS) + } + if n.Sources != 2 { + t.Errorf("distinct sources = %d, want 2", n.Sources) + } + if len(n.CVEs) != 1 || n.CVEs[0] != "CVE-2026-1" { + t.Errorf("cves wrong: %v", n.CVEs) + } + if n.Score != 0.77 { + t.Errorf("score = %v, want 0.77", n.Score) + } +} + +func TestResolveWatchInterval(t *testing.T) { + cfg := config.Default() + watchInterval = "" + defer func() { watchInterval = "" }() + + if d, err := resolveWatchInterval(cfg); err != nil || d != time.Hour { + t.Errorf("default interval = %v, %v; want 1h, nil", d, err) + } + + watchInterval = "30m" + if d, err := resolveWatchInterval(cfg); err != nil || d != 30*time.Minute { + t.Errorf("flag override = %v, %v; want 30m, nil", d, err) + } + + watchInterval = "5s" + if _, err := resolveWatchInterval(cfg); err == nil { + t.Error("expected an error for a sub-minimum interval") + } + + watchInterval = "nonsense" + if _, err := resolveWatchInterval(cfg); err == nil { + t.Error("expected an error for a garbage interval") + } +} + +func TestValidateWebhookURL(t *testing.T) { + good := []string{"https://hooks.slack.com/services/x", "http://127.0.0.1:39871/hook"} + for _, u := range good { + if err := validateWebhookURL(u); err != nil { + t.Errorf("validateWebhookURL(%q) = %v, want nil", u, err) + } + } + bad := []string{"example.com/hook", "ftp://x/y", "not a url", ""} + for _, u := range bad { + if err := validateWebhookURL(u); err == nil { + t.Errorf("validateWebhookURL(%q) = nil, want error", u) + } + } +} + +func TestBuildNotableCapsToNotifyMax(t *testing.T) { + st, err := store.Open(filepath.Join(t.TempDir(), "watch.db")) + if err != nil { + t.Fatal(err) + } + defer st.Close() + + src, err := st.UpsertSource(store.SourceInput{Name: "s", URL: "https://s/f", Type: "rss", Weight: 1, Enabled: true}) + if err != nil { + t.Fatal(err) + } + var rows []store.ClusterRow + for i := 0; i < 5; i++ { + id, err := st.InsertArticle(store.Article{ + SourceID: src, CanonicalURL: fmt.Sprintf("https://s/%d", i), + ContentHash: "c" + strconv.Itoa(i), TitleHash: "t" + strconv.Itoa(i), + Title: "story " + strconv.Itoa(i), PublishedAt: 10000, FetchedAt: 10000, + }) + if err != nil { + t.Fatal(err) + } + rows = append(rows, store.ClusterRow{Key: strconv.Itoa(i), Members: []int64{id}, FirstSeen: 10000, LastSeen: 10000}) + } + if err := st.ReplaceClusters(rows); err != nil { + t.Fatal(err) + } + + cfg := config.Default() + cfg.Watch.NotifyMinScore = 0 + cfg.Watch.NotifyMaxItems = 2 + + items, err := buildNotable(st, cfg, time.Unix(9999, 0)) + if err != nil { + t.Fatal(err) + } + if len(items) != 2 { + t.Fatalf("buildNotable returned %d items, want the notify_max_items cap of 2", len(items)) + } +} diff --git a/PROJECTS/intermediate/security-news-scraper/go.mod b/PROJECTS/intermediate/security-news-scraper/go.mod new file mode 100644 index 00000000..f51665b2 --- /dev/null +++ b/PROJECTS/intermediate/security-news-scraper/go.mod @@ -0,0 +1,56 @@ +module github.com/CarterPerez-dev/nadezhda + +go 1.25.0 + +require ( + github.com/PuerkitoBio/goquery v1.12.0 + github.com/charmbracelet/bubbles v1.0.0 + github.com/charmbracelet/bubbletea v1.3.10 + github.com/charmbracelet/lipgloss v1.1.0 + github.com/mmcdole/gofeed v1.3.0 + github.com/spf13/cobra v1.10.2 + github.com/temoto/robotstxt v1.1.2 + golang.org/x/sync v0.21.0 + golang.org/x/term v0.41.0 + golang.org/x/time v0.15.0 + gopkg.in/yaml.v3 v3.0.1 + modernc.org/sqlite v1.53.0 +) + +require ( + github.com/andybalholm/cascadia v1.3.3 // indirect + github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect + github.com/charmbracelet/colorprofile v0.4.1 // indirect + github.com/charmbracelet/x/ansi v0.11.6 // indirect + github.com/charmbracelet/x/cellbuf v0.0.15 // indirect + github.com/charmbracelet/x/term v0.2.2 // indirect + github.com/clipperhouse/displaywidth v0.9.0 // indirect + github.com/clipperhouse/stringish v0.1.1 // indirect + github.com/clipperhouse/uax29/v2 v2.5.0 // indirect + github.com/dustin/go-humanize v1.0.1 // indirect + github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect + github.com/google/uuid v1.6.0 // indirect + github.com/inconshreveable/mousetrap v1.1.0 // indirect + github.com/json-iterator/go v1.1.12 // indirect + github.com/lucasb-eyer/go-colorful v1.3.0 // indirect + github.com/mattn/go-isatty v0.0.20 // indirect + github.com/mattn/go-localereader v0.0.1 // indirect + github.com/mattn/go-runewidth v0.0.19 // indirect + github.com/mmcdole/goxpp v1.1.1-0.20240225020742-a0c311522b23 // indirect + github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect + github.com/modern-go/reflect2 v1.0.2 // indirect + github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect + github.com/muesli/cancelreader v0.2.2 // indirect + github.com/muesli/termenv v0.16.0 // indirect + github.com/ncruces/go-strftime v1.0.0 // indirect + github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect + github.com/rivo/uniseg v0.4.7 // indirect + github.com/spf13/pflag v1.0.9 // indirect + github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect + golang.org/x/net v0.52.0 // indirect + golang.org/x/sys v0.44.0 // indirect + golang.org/x/text v0.35.0 // indirect + modernc.org/libc v1.73.4 // indirect + modernc.org/mathutil v1.7.1 // indirect + modernc.org/memory v1.11.0 // indirect +) diff --git a/PROJECTS/intermediate/security-news-scraper/go.sum b/PROJECTS/intermediate/security-news-scraper/go.sum new file mode 100644 index 00000000..5445ca88 --- /dev/null +++ b/PROJECTS/intermediate/security-news-scraper/go.sum @@ -0,0 +1,207 @@ +github.com/PuerkitoBio/goquery v1.12.0 h1:pAcL4g3WRXekcB9AU/y1mbKez2dbY2AajVhtkO8RIBo= +github.com/PuerkitoBio/goquery v1.12.0/go.mod h1:802ej+gV2y7bbIhOIoPY5sT183ZW0YFofScC4q/hIpQ= +github.com/andybalholm/cascadia v1.3.3 h1:AG2YHrzJIm4BZ19iwJ/DAua6Btl3IwJX+VI4kktS1LM= +github.com/andybalholm/cascadia v1.3.3/go.mod h1:xNd9bqTn98Ln4DwST8/nG+H0yuB8Hmgu1YHNnWw0GeA= +github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k= +github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8= +github.com/charmbracelet/bubbles v1.0.0 h1:12J8/ak/uCZEMQ6KU7pcfwceyjLlWsDLAxB5fXonfvc= +github.com/charmbracelet/bubbles v1.0.0/go.mod h1:9d/Zd5GdnauMI5ivUIVisuEm3ave1XwXtD1ckyV6r3E= +github.com/charmbracelet/bubbletea v1.3.10 h1:otUDHWMMzQSB0Pkc87rm691KZ3SWa4KUlvF9nRvCICw= +github.com/charmbracelet/bubbletea v1.3.10/go.mod h1:ORQfo0fk8U+po9VaNvnV95UPWA1BitP1E0N6xJPlHr4= +github.com/charmbracelet/colorprofile v0.4.1 h1:a1lO03qTrSIRaK8c3JRxJDZOvhvIeSco3ej+ngLk1kk= +github.com/charmbracelet/colorprofile v0.4.1/go.mod h1:U1d9Dljmdf9DLegaJ0nGZNJvoXAhayhmidOdcBwAvKk= +github.com/charmbracelet/lipgloss v1.1.0 h1:vYXsiLHVkK7fp74RkV7b2kq9+zDLoEU4MZoFqR/noCY= +github.com/charmbracelet/lipgloss v1.1.0/go.mod h1:/6Q8FR2o+kj8rz4Dq0zQc3vYf7X+B0binUUBwA0aL30= +github.com/charmbracelet/x/ansi v0.11.6 h1:GhV21SiDz/45W9AnV2R61xZMRri5NlLnl6CVF7ihZW8= +github.com/charmbracelet/x/ansi v0.11.6/go.mod h1:2JNYLgQUsyqaiLovhU2Rv/pb8r6ydXKS3NIttu3VGZQ= +github.com/charmbracelet/x/cellbuf v0.0.15 h1:ur3pZy0o6z/R7EylET877CBxaiE1Sp1GMxoFPAIztPI= +github.com/charmbracelet/x/cellbuf v0.0.15/go.mod h1:J1YVbR7MUuEGIFPCaaZ96KDl5NoS0DAWkskup+mOY+Q= +github.com/charmbracelet/x/term v0.2.2 h1:xVRT/S2ZcKdhhOuSP4t5cLi5o+JxklsoEObBSgfgZRk= +github.com/charmbracelet/x/term v0.2.2/go.mod h1:kF8CY5RddLWrsgVwpw4kAa6TESp6EB5y3uxGLeCqzAI= +github.com/clipperhouse/displaywidth v0.9.0 h1:Qb4KOhYwRiN3viMv1v/3cTBlz3AcAZX3+y9OLhMtAtA= +github.com/clipperhouse/displaywidth v0.9.0/go.mod h1:aCAAqTlh4GIVkhQnJpbL0T/WfcrJXHcj8C0yjYcjOZA= +github.com/clipperhouse/stringish v0.1.1 h1:+NSqMOr3GR6k1FdRhhnXrLfztGzuG+VuFDfatpWHKCs= +github.com/clipperhouse/stringish v0.1.1/go.mod h1:v/WhFtE1q0ovMta2+m+UbpZ+2/HEXNWYXQgCt4hdOzA= +github.com/clipperhouse/uax29/v2 v2.5.0 h1:x7T0T4eTHDONxFJsL94uKNKPHrclyFI0lm7+w94cO8U= +github.com/clipperhouse/uax29/v2 v2.5.0/go.mod h1:Wn1g7MK6OoeDT0vL+Q0SQLDz/KpfsVRgg6W7ihQeh4g= +github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= +github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= +github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f h1:Y/CXytFA4m6baUTXGLOoWe4PQhGxaX0KpnayAqC48p4= +github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f/go.mod h1:vw97MGsxSvLiUE2X8qFplwetxpGLQrlU1Q9AUEIzCaM= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/pprof v0.0.0-20250317173921-a4b03ec1a45e h1:ijClszYn+mADRFY17kjQEVQ1XRhq2/JR1M3sGqeJoxs= +github.com/google/pprof v0.0.0-20250317173921-a4b03ec1a45e/go.mod h1:boTsfXsheKC2y+lKOCMpSfarhxDeIzfZG1jqGcPl3cA= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k= +github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM= +github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= +github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= +github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= +github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= +github.com/lucasb-eyer/go-colorful v1.3.0 h1:2/yBRLdWBZKrf7gB40FoiKfAWYQ0lqNcbuQwVHXptag= +github.com/lucasb-eyer/go-colorful v1.3.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0= +github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= +github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/mattn/go-localereader v0.0.1 h1:ygSAOl7ZXTx4RdPYinUpg6W99U8jWvWi9Ye2JC/oIi4= +github.com/mattn/go-localereader v0.0.1/go.mod h1:8fBrzywKY7BI3czFoHkuzRoWE9C+EiG4R1k4Cjx5p88= +github.com/mattn/go-runewidth v0.0.19 h1:v++JhqYnZuu5jSKrk9RbgF5v4CGUjqRfBm05byFGLdw= +github.com/mattn/go-runewidth v0.0.19/go.mod h1:XBkDxAl56ILZc9knddidhrOlY5R/pDhgLpndooCuJAs= +github.com/mmcdole/gofeed v1.3.0 h1:5yn+HeqlcvjMeAI4gu6T+crm7d0anY85+M+v6fIFNG4= +github.com/mmcdole/gofeed v1.3.0/go.mod h1:9TGv2LcJhdXePDzxiuMnukhV2/zb6VtnZt1mS+SjkLE= +github.com/mmcdole/goxpp v1.1.1-0.20240225020742-a0c311522b23 h1:Zr92CAlFhy2gL+V1F+EyIuzbQNbSgP4xhTODZtrXUtk= +github.com/mmcdole/goxpp v1.1.1-0.20240225020742-a0c311522b23/go.mod h1:v+25+lT2ViuQ7mVxcncQ8ch1URund48oH+jhjiwEgS8= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= +github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= +github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 h1:ZK8zHtRHOkbHy6Mmr5D264iyp3TiX5OmNcI5cIARiQI= +github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6/go.mod h1:CJlz5H+gyd6CUWT45Oy4q24RdLyn7Md9Vj2/ldJBSIo= +github.com/muesli/cancelreader v0.2.2 h1:3I4Kt4BQjOR54NavqnDogx/MIoWBFa0StPA8ELUXHmA= +github.com/muesli/cancelreader v0.2.2/go.mod h1:3XuTXfFS2VjM+HTLZY9Ak0l6eUKfijIfMUZ4EgX0QYo= +github.com/muesli/termenv v0.16.0 h1:S5AlUN9dENB57rsbnkPyfdGuWIlkmzJjbFf0Tf5FWUc= +github.com/muesli/termenv v0.16.0/go.mod h1:ZRfOIKPFDYQoDFF4Olj7/QJbW60Ol/kL1pU3VfY/Cnk= +github.com/ncruces/go-strftime v1.0.0 h1:HMFp8mLCTPp341M/ZnA4qaf7ZlsbTc+miZjCLOFAw7w= +github.com/ncruces/go-strftime v1.0.0/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE= +github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= +github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= +github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= +github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/spf13/cobra v1.10.2 h1:DMTTonx5m65Ic0GOoRY2c16WCbHxOOw6xxezuLaBpcU= +github.com/spf13/cobra v1.10.2/go.mod h1:7C1pvHqHw5A4vrJfjNwvOdzYu0Gml16OCs2GRiTUUS4= +github.com/spf13/pflag v1.0.9 h1:9exaQaMOCwffKiiiYk6/BndUBv+iRViNW+4lEMi0PvY= +github.com/spf13/pflag v1.0.9/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= +github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/temoto/robotstxt v1.1.2 h1:W2pOjSJ6SWvldyEuiFXNxz3xZ8aiWX5LbfDiOFd7Fxg= +github.com/temoto/robotstxt v1.1.2/go.mod h1:+1AmkuG3IYkh1kv0d2qEB9Le88ehNO0zwOr3ujewlOo= +github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no= +github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM= +github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= +go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc= +golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= +golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8= +golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk= +golang.org/x/exp v0.0.0-20231006140011-7918f672742d h1:jtJma62tbqLibJ5sFQz8bKtEM8rJBtfilJ2qTU199MI= +golang.org/x/exp v0.0.0-20231006140011-7918f672742d/go.mod h1:ldy0pHrwJyGW56pPQzzkH36rKxoZW1tw7ZJpeKx+hdo= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= +golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/mod v0.36.0 h1:JJjpVx6myfUsUdAzZuOSTTmRE0PfZeNWzzvKrP7amb4= +golang.org/x/mod v0.36.0/go.mod h1:moc6ELqsWcOw5Ef3xVprK5ul/MvtVvkIXLziUOICjUQ= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= +golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk= +golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= +golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= +golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= +golang.org/x/net v0.52.0 h1:He/TN1l0e4mmR3QqHMT2Xab3Aj3L9qjbhRm78/6jrW0= +golang.org/x/net v0.52.0/go.mod h1:R1MAz7uMZxVMualyPXb+VaqGSa3LIaUqk0eEt3w36Sw= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= +golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.21.0 h1:HLII4xRRTtCRkxYp4HNFF0Js/Og6q2i++KXbg0gHCwM= +golang.org/x/sync v0.21.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.44.0 h1:ildZl3J4uzeKP07r2F++Op7E9B29JRUy+a27EibtBTQ= +golang.org/x/sys v0.44.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw= +golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= +golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= +golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU= +golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= +golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY= +golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM= +golang.org/x/term v0.41.0 h1:QCgPso/Q3RTJx2Th4bDLqML4W6iJiaXFq2/ftQF13YU= +golang.org/x/term v0.41.0/go.mod h1:3pfBgksrReYfZ5lvYM0kSO0LIkAl4Yl2bXOkKP7Ec2A= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= +golang.org/x/text v0.35.0 h1:JOVx6vVDFokkpaq1AEptVzLTpDe9KGpj5tR4/X+ybL8= +golang.org/x/text v0.35.0/go.mod h1:khi/HExzZJ2pGnjenulevKNX1W67CUy0AsXcNubPGCA= +golang.org/x/time v0.15.0 h1:bbrp8t3bGUeFOx08pvsMYRTCVSMk89u4tKbNOZbp88U= +golang.org/x/time v0.15.0/go.mod h1:Y4YMaQmXwGQZoFaVFk4YpCt4FLQMYKZe9oeV/f4MSno= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= +golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= +golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58= +golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= +golang.org/x/tools v0.45.0 h1:18qN3FAooORvApf5XjCXgsuayZOEtXf6JK18I3+ONa8= +golang.org/x/tools v0.45.0/go.mod h1:LuUGqqaXcXMEFEruIVJVm5mgDD8vww/z/SR1gQ4uE/0= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +modernc.org/cc/v4 v4.28.4 h1:Hd/4Es+MBj+/7hSdZaisNyu6bv3V0Dp2MdllyfqaH+c= +modernc.org/cc/v4 v4.28.4/go.mod h1:OnovgIhbbMXMu1aISnJ0wvVD1KnW+cAUJkIrAWh+kVI= +modernc.org/ccgo/v4 v4.34.4 h1:OVnSOWQjVKOYkFxoHYB+qQmSHK5gqMqARM+K9DpR/Ws= +modernc.org/ccgo/v4 v4.34.4/go.mod h1:qdKqE8FNIYyysougB1RX9MxCzp5oJOcQXSobANJ4TuE= +modernc.org/fileutil v1.4.0 h1:j6ZzNTftVS054gi281TyLjHPp6CPHr2KCxEXjEbD6SM= +modernc.org/fileutil v1.4.0/go.mod h1:EqdKFDxiByqxLk8ozOxObDSfcVOv/54xDs/DUHdvCUU= +modernc.org/gc/v2 v2.6.5 h1:nyqdV8q46KvTpZlsw66kWqwXRHdjIlJOhG6kxiV/9xI= +modernc.org/gc/v2 v2.6.5/go.mod h1:YgIahr1ypgfe7chRuJi2gD7DBQiKSLMPgBQe9oIiito= +modernc.org/gc/v3 v3.1.3 h1:6QAplYyVO+KdPW3pGnqmJDUxtkec8ooEWvks/hhU3lc= +modernc.org/gc/v3 v3.1.3/go.mod h1:HFK/6AGESC7Ex+EZJhJ2Gni6cTaYpSMmU/cT9RmlfYY= +modernc.org/goabi0 v0.2.0 h1:HvEowk7LxcPd0eq6mVOAEMai46V+i7Jrj13t4AzuNks= +modernc.org/goabi0 v0.2.0/go.mod h1:CEFRnnJhKvWT1c1JTI3Avm+tgOWbkOu5oPA8eH8LnMI= +modernc.org/libc v1.73.4 h1:+ra4Ui8ngyt8HDcO1FTDPWlkAh6yOdaO2yAoh8MddQA= +modernc.org/libc v1.73.4/go.mod h1:DXZ3eO8qMCNn2SnmTNCiC71nJ9Rcq3PsnpU6Vc4rWK8= +modernc.org/mathutil v1.7.1 h1:GCZVGXdaN8gTqB1Mf/usp1Y/hSqgI2vAGGP4jZMCxOU= +modernc.org/mathutil v1.7.1/go.mod h1:4p5IwJITfppl0G4sUEDtCr4DthTaT47/N3aT6MhfgJg= +modernc.org/memory v1.11.0 h1:o4QC8aMQzmcwCK3t3Ux/ZHmwFPzE6hf2Y5LbkRs+hbI= +modernc.org/memory v1.11.0/go.mod h1:/JP4VbVC+K5sU2wZi9bHoq2MAkCnrt2r98UGeSK7Mjw= +modernc.org/opt v0.2.0 h1:tGyef5ApycA7FSEOMraay9SaTk5zmbx7Tu+cJs4QKZg= +modernc.org/opt v0.2.0/go.mod h1:03fq9lsNfvkYSfxrfUhZCWPk1lm4cq4N+Bh//bEtgns= +modernc.org/sortutil v1.2.1 h1:+xyoGf15mM3NMlPDnFqrteY07klSFxLElE2PVuWIJ7w= +modernc.org/sortutil v1.2.1/go.mod h1:7ZI3a3REbai7gzCLcotuw9AC4VZVpYMjDzETGsSMqJE= +modernc.org/sqlite v1.53.0 h1:20WG8N9q4ji/dEqGk4uiI0c6OPjSeLTNYGFCc3+7c1M= +modernc.org/sqlite v1.53.0/go.mod h1:xoEpOIpGrgT48H5iiyt/YXPCZPEzlfmfFwtk8Lklw8s= +modernc.org/strutil v1.2.1 h1:UneZBkQA+DX2Rp35KcM69cSsNES9ly8mQWD71HKlOA0= +modernc.org/strutil v1.2.1/go.mod h1:EHkiggD70koQxjVdSBM3JKM7k6L0FbGE5eymy9i3B9A= +modernc.org/token v1.1.0 h1:Xl7Ap9dKaEs5kLoOQeQmPWevfnk/DM5qcLcYlA8ys6Y= +modernc.org/token v1.1.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM= diff --git a/PROJECTS/intermediate/security-news-scraper/install.sh b/PROJECTS/intermediate/security-news-scraper/install.sh new file mode 100755 index 00000000..115d1e6a --- /dev/null +++ b/PROJECTS/intermediate/security-news-scraper/install.sh @@ -0,0 +1,259 @@ +#!/usr/bin/env bash +# ©AngelaMos | 2026 +# install.sh +# +# One-shot installer for nadezhda. Takes a fresh machine to `nadezhda` runnable +# by its bare name, with zero further steps, whether run from a clone or piped +# from a domain via curl. Prefers a prebuilt release binary (no Go needed); +# falls back to building from source (auto-installs the Go toolchain if absent). + +set -euo pipefail + +# ============================================================================ +# CONFIG +# ============================================================================ +REPO_OWNER="CarterPerez-dev" +REPO_NAME="nadezhda" +BINARY="nadezhda" +TAGLINE="Security news + CVE intelligence in your terminal. Keyless by default." +REPO_URL="https://github.com/${REPO_OWNER}/${REPO_NAME}.git" +INSTALL_DIR="${NADEZHDA_INSTALL_DIR:-$HOME/.local/bin}" +DEFAULT_BRANCH="main" +GO_MIN="1.21" +PREBUILT=1 + +# ============================================================================ +# Colors +# ============================================================================ +if [ -t 2 ] && [ -z "${NO_COLOR:-}" ]; then + BOLD=$'\033[1m'; DIM=$'\033[2m'; RED=$'\033[31m'; GREEN=$'\033[32m' + YELLOW=$'\033[33m'; CYAN=$'\033[36m'; RESET=$'\033[0m' +else + BOLD=""; DIM=""; RED=""; GREEN=""; YELLOW=""; CYAN=""; RESET="" +fi + +info() { printf '%s\n' " ${CYAN}+${RESET} $*" >&2; } +ok() { printf '%s\n' " ${GREEN}+${RESET} $*" >&2; } +warn() { printf '%s\n' " ${YELLOW}!${RESET} $*" >&2; } +die() { printf '%s\n' " ${RED}x $*${RESET}" >&2; exit 1; } +header(){ printf '\n%s\n\n' "${BOLD}${CYAN}--- $* ---${RESET}" >&2; } +have() { command -v "$1" >/dev/null 2>&1; } + +trap 'printf "%s\n" "${RED}x install failed${RESET}" >&2' ERR +TMP_DIR="" +cleanup() { [ -n "$TMP_DIR" ] && rm -rf "$TMP_DIR"; return 0; } +trap cleanup EXIT + +banner() { + printf '%s' "${CYAN}${BOLD}" >&2 + cat >&2 <<'ART' + ╭───────────────────────╮ + │ n a d e z h d a │ + ╰───────────────────────╯ +ART + printf '%s\n' "${RESET}" >&2 + printf '%s\n' " ${DIM}${TAGLINE}${RESET}" >&2 +} + +# ============================================================================ +# Privilege + package-manager fan +# ============================================================================ +SUDO="" +if [ "$(id -u)" -ne 0 ]; then + if have sudo; then SUDO="sudo"; fi +fi + +pkg_install() { + if have apt-get; then $SUDO apt-get update -y || warn "apt update had errors; continuing" + $SUDO apt-get install -y --no-install-recommends "$@" + elif have dnf; then $SUDO dnf install -y "$@" + elif have pacman; then $SUDO pacman -S --needed --noconfirm "$@" + elif have zypper; then $SUDO zypper install -y "$@" + elif have apk; then $SUDO apk add "$@" + elif have brew; then brew install "$@" + else die "no known package manager. Install manually: $*"; fi +} + +download() { + if have curl; then curl -fsSL "$1" -o "$2" || return 1 + elif have wget; then wget -qO "$2" "$1" || return 1 + else die "need curl or wget"; fi +} + +# ============================================================================ +# Args +# ============================================================================ +usage() { + cat >&2 </dev/null || warn "pull failed; using existing clone" + else + info "cloning ${REPO_URL}" + git clone --depth 1 --branch "$DEFAULT_BRANCH" --quiet "$REPO_URL" "$cache" \ + || die "clone failed from ${REPO_URL}" + fi + printf '%s\n' "$cache" +} + +# ============================================================================ +# Toolchain (Go) + build from source +# ============================================================================ +install_go() { + info "installing a current Go toolchain" + local latest tgz + latest="$(download "https://go.dev/VERSION?m=text" /dev/stdout 2>/dev/null | head -n1)" || latest="" + case "$latest" in go*) ;; *) latest="go1.25.5" ;; esac + tgz="${latest}.${OS}-${ARCH}.tar.gz" + TMP_DIR="${TMP_DIR:-$(mktemp -d)}" + download "https://go.dev/dl/${tgz}" "$TMP_DIR/go.tgz" || die "failed to download ${tgz} from go.dev/dl" + rm -rf "$HOME/.local/go" + mkdir -p "$HOME/.local" + tar -C "$HOME/.local" -xzf "$TMP_DIR/go.tgz" || die "failed to extract Go" + export PATH="$HOME/.local/go/bin:$PATH" + export GOTOOLCHAIN=auto + have go || die "Go toolchain install failed" + ok "go $(go env GOVERSION 2>/dev/null | sed 's/^go//') at ~/.local/go" +} + +need_toolchain() { + local cur + if have go; then + cur="$(go env GOVERSION 2>/dev/null | sed 's/^go//')" + if [ -n "$cur" ] && [ "$(printf '%s\n%s\n' "$GO_MIN" "$cur" | sort -V | head -n1)" = "$GO_MIN" ]; then + export GOTOOLCHAIN=auto + ok "go $cur (auto-toolchain fetches the go.mod-pinned version if newer)" + return + fi + warn "go ${cur:-unknown} predates toolchain auto-download; installing a current Go" + fi + install_go +} + +build_from_source() { + info "building ${BINARY} (compiles the pure-Go SQLite driver; give it a minute)" + mkdir -p "$INSTALL_DIR" + GOBIN="$INSTALL_DIR" go install ./cmd/nadezhda || die "go install failed" + ok "installed ${BINARY} -> ${INSTALL_DIR}/${BINARY}" +} + +try_prebuilt() { + [ "$PREBUILT" = "1" ] || return 1 + local ver archive url + ver="$(download "https://api.github.com/repos/${REPO_OWNER}/${REPO_NAME}/releases/latest" /dev/stdout 2>/dev/null \ + | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')" || true + [ -n "$ver" ] || return 1 + archive="${BINARY}_${ver#v}_${OS}_${ARCH}.tar.gz" + url="https://github.com/${REPO_OWNER}/${REPO_NAME}/releases/download/${ver}/${archive}" + TMP_DIR="$(mktemp -d)" + download "$url" "$TMP_DIR/a.tgz" || { warn "no prebuilt for ${OS}/${ARCH}; will build from source"; return 1; } + tar -xzf "$TMP_DIR/a.tgz" -C "$TMP_DIR" || return 1 + mkdir -p "$INSTALL_DIR"; install -m 0755 "$TMP_DIR/$BINARY" "$INSTALL_DIR/$BINARY" + ok "installed prebuilt ${ver} -> ${INSTALL_DIR}/${BINARY}" +} + +# ============================================================================ +# PATH wiring +# ============================================================================ +wire_path() { + case ":$PATH:" in *":$INSTALL_DIR:"*) ok "$INSTALL_DIR already on PATH"; return ;; esac + local shell rc="" + shell="$(basename "${SHELL:-bash}")" + case "$shell" in + zsh) rc="$HOME/.zshrc" ;; + fish) mkdir -p "$HOME/.config/fish/conf.d" + echo "fish_add_path $INSTALL_DIR" > "$HOME/.config/fish/conf.d/${BINARY}.fish" + ok "added to fish conf.d" ;; + bash) rc="$HOME/.bashrc"; [ -f "$rc" ] || rc="$HOME/.bash_profile" ;; + *) rc="$HOME/.profile" ;; + esac + if [ -n "$rc" ] && ! grep -q "$INSTALL_DIR" "$rc" 2>/dev/null; then + printf '\nexport PATH="%s:$PATH"\n' "$INSTALL_DIR" >> "$rc" + ok "added $INSTALL_DIR to PATH in $rc" + fi + export PATH="$INSTALL_DIR:$PATH" +} + +# ============================================================================ +# Main +# ============================================================================ +main() { + banner + have "$BINARY" && info "existing install at $(command -v "$BINARY") — updating" + + REPO="" + if ! try_prebuilt; then + header "Building from source" + REPO="$(resolve_repo)"; cd "$REPO" + need_toolchain + build_from_source + fi + + wire_path + + header "Verify" + if have "$BINARY"; then + ok "$BINARY -> $(command -v "$BINARY")" + "$BINARY" version 2>/dev/null || true + else + warn "installed to $INSTALL_DIR but not yet on PATH — open a new shell" + fi + + printf '\n%s\n\n' " ${GREEN}${BOLD}${BINARY} is ready.${RESET}" >&2 + if have just && [ -n "$REPO" ] && [ -f "${REPO}/justfile" ]; then + printf '%s\n' " ${DIM}dev commands:${RESET} just" >&2 + fi + cat >&2 <