All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.joern.rubysrc2cpg.passes.ConfigFileCreationPass.scala Maven / Gradle / Ivy

There is a newer version: 4.0.78
Show newest version
package io.joern.rubysrc2cpg.passes

import better.files.File
import io.joern.x2cpg.passes.frontend.XConfigFileCreationPass
import io.shiftleft.codepropertygraph.generated.Cpg
import io.shiftleft.semanticcpg.language.*

import scala.util.Try

/** Creates the CONFIGURATION layer from any existing `Gemfile` or `Gemfile.lock` files found at root level.
  */
class ConfigFileCreationPass(cpg: Cpg) extends XConfigFileCreationPass(cpg) {

  private val validGemfilePaths = Try(File(cpg.metaData.root.headOption.getOrElse(""))).toOption match {
    case Some(rootPath) => Seq("Gemfile", "Gemfile.lock").map(rootPath / _)
    case None           => Seq()
  }

  override protected val configFileFilters: List[File => Boolean] = List(
    // Gemfiles
    validGemfilePaths.contains,
    extensionFilter(".ini"),
    // YAML files
    extensionFilter(".yaml"),
    extensionFilter(".yml"),
    // XML files
    extensionFilter(".xml"),
    // ERB files
    extensionFilter(".erb")
  )
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy