Skip to content

Commit

Permalink
Enhance tools data handling by backfilling deprecated fields and addi…
Browse files Browse the repository at this point in the history
…ng performance category
  • Loading branch information
mre committed Jan 6, 2025
1 parent 191e3fe commit 9c526a0
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 5 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ Also check out the sister project, [awesome-dynamic-analysis](https://github.com

- [Gendarme](https://www.mono-project.com/docs/tools+libraries/tools/gendarme) — Gendarme inspects programs and libraries that contain code in ECMA CIL format (Mono and .NET).

- [Infer#](https://github.com/microsoft/infersharp) :warning: — InferSharp (also referred to as Infer#) is an interprocedural and scalable static code analyzer for C#. Via the capabilities of Facebook's Infer, this tool detects null pointer dereferences and resource leaks.
- [Infer#](https://github.com/microsoft/infersharp) — InferSharp (also referred to as Infer#) is an interprocedural and scalable static code analyzer for C#. Via the capabilities of Facebook's Infer, this tool detects null pointer dereferences and resource leaks.

- [Meziantou.Analyzer](https://github.com/meziantou/Meziantou.Analyzer) — A Roslyn analyzer to enforce some good practices in C# in terms of design, usage, security, performance, and style.

Expand Down Expand Up @@ -1698,7 +1698,7 @@ Loading address: binbloom can parse a raw binary firmware and determine its load

- [Ghidra](https://ghidra-sre.org) — A software reverse engineering (SRE) suite of tools developed by NSA's Research Directorate in support of the Cybersecurity mission

- [Hopper](https://www.hopperapp.com/) :copyright: — macOS and Linux reverse engineering tool that lets you disassemble, decompile and debug applications. Hopper displays the code using different representations, e.g. the Control Flow Graph, and the pseudo-code of a procedure. Supports Apple Silicon.
- [Hopper](https://www.hopperapp.com/) :warning: :copyright: — macOS and Linux reverse engineering tool that lets you disassemble, decompile and debug applications. Hopper displays the code using different representations, e.g. the Control Flow Graph, and the pseudo-code of a procedure. Supports Apple Silicon.

- [IDA Free](https://www.hex-rays.com/products/ida/support/download_freeware) :copyright: — Binary code analysis tool.

Expand Down
31 changes: 28 additions & 3 deletions data/render/src/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use askama::Template;
use pico_args::Arguments;
use render::types::{Entry, ParsedEntry, Tag, Tags, Type};
use render::{check_deprecated, create_api, create_catalog};
use slug::slugify;
use std::collections::BTreeMap;
use std::env;
use std::ffi::OsStr;
Expand Down Expand Up @@ -49,6 +50,24 @@ fn read_tools(path: PathBuf) -> Result<Vec<ParsedEntry>> {
.collect::<Result<Vec<ParsedEntry>, _>>()
}

/// Backfills the deprecated field in the tools data from the old tools data.
fn backfill_deprecated(tools: &mut Vec<Entry>) -> Result<()> {
let tools_raw = match fs::read_to_string("data/api/tools.json") {
Ok(content) => content,
Err(_) => return Ok(()), // No old data to backfill from. Skip silently.
};

let old_tools_data: BTreeMap<String, serde_json::Value> = serde_json::from_str(&tools_raw)?;

for tool in tools {
let id = slugify(&tool.name);
if let Some(old_tool) = old_tools_data.get(&id) {
tool.deprecated = old_tool.get("deprecated").and_then(|d| d.as_bool());
}
}
Ok(())
}

fn main() -> Result<()> {
let mut args = Arguments::from_env();
let args = Args {
Expand All @@ -69,10 +88,16 @@ fn main() -> Result<()> {
let mut tools = tools?;
tools.sort();

if !args.skip_deprecated {
if let Ok(token) = env::var("GITHUB_TOKEN") {
check_deprecated(token, &mut tools)?;
let should_check_deprecation = !args.skip_deprecated;
let github_token = env::var("GITHUB_TOKEN");

match (should_check_deprecation, github_token) {
(true, Ok(token)) => check_deprecated(token, &mut tools)?,
(true, Err(_)) => {
eprintln!("No GITHUB_TOKEN environment variable found. Reusing old deprecation data.");
backfill_deprecated(&mut tools)?;
}
(false, _) => backfill_deprecated(&mut tools)?,
}

let languages: Vec<Tag> = tags
Expand Down
2 changes: 2 additions & 0 deletions data/render/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ pub enum Category {
Linter,
#[serde(rename = "formatter")]
Formatter,
#[serde(rename = "performance")]
Performance,
#[serde(rename = "meta")]
Meta,
}
Expand Down

0 comments on commit 9c526a0

Please sign in to comment.