DEV Community

Discussion on: I Detect 26 Frameworks Without AI. Here's How Deterministic File-Based Detection Works.

Collapse
 
xwero profile image
david duymelinck

Isn't the files lookup a cause for false positives?

I'm no ruby expert so I checked and config.ru isn't the config file. .ru was the giveaway, because the ruby extension is .rb. so I think that is a typo.
Config.rb can be the Chef configuration file. And I assume there are other solutions that look for that file.
The Rails main config file is config/application.rb.

The first place I would look to find the framework are the package manager files. There can be multiple when the project uses multiple languages.
The package manager file itself tells you nothing about the framework. You seem to suggest it does in the case of Rails.

I'm focussing on Rails because that was the one solution that I found being off.

Collapse
 
jonny2k26 profile image
Jonathan Pitter

You're right in that I would need to be more specific when looking at files. Thanks for that.

config.ru is a Rackup file (.ru = rackup), not a Ruby config file. It's present in any Rack-based app, Sinatra, Hanami, Roda, not just Rails.

stackoverflow.com/questions/550728...

The way Phase 1 works, if any marker in detect_files matches, the framework is detected. Since Rails is higher priority than Sinatra, a Sinatra app with a Gemfile and config.ru would be incorrectly detected as Rails. That's a false positive.

So I'm thinking of narrowing Rails' Phase 1 markers down to just bin/rails, the only file that's genuinely Rails-specific. Then let Phase 2 handle the rest by checking for the rails gem inside the Gemfile. That way:

  • bin/rails present → Rails, high confidence (Phase 1)
  • Gemfile with rails gem → Rails, medium confidence (Phase 2)
  • Gemfile with sinatra gem → Sinatra, medium confidence (Phase 2)
  • config.ru alone → Sinatra catches it via its own detect_files

I'll update the rules and try some evaluations when I get some free time today. Then update this post.