Skip to content

Commit

Permalink
feat: remove slashes in dep reports
Browse files Browse the repository at this point in the history
  • Loading branch information
jsterner30 committed Apr 4, 2024
1 parent 016fa5f commit 194c8b7
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default function (ruleFile: RuleFile): DockerfileImageParts | null {
let imageParts: DockerfileImageParts | null = null
if (validDockerfile.Check(ruleFile) && ruleFile.fileType === FileTypeEnum.DOCKERFILE) {
const imageArray = ruleFile.image.split(':')
const image = imageArray[0].replace(/\//g, '_') // slashes in image name will mess with file structure
const image = imageArray[0]
let version = '?'
let tag = '?'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default function (ruleFile: RuleFile): GHActionModuleParts[] {
if (step.uses != null) {
const moduleString = step.uses.split('@')
if (moduleString[1] != null) {
const moduleName: string = moduleString[0].replace(/\//g, '_') // slashes in action name will mess with file structure
const moduleName: string = moduleString[0]
const version = moduleString[1]
parts.push({
name: moduleName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default function (ruleFile: RuleFile): NPMDependencyParts[] {
const allDeps: Record<string, string> = combineDeps(ruleFile)

for (const name in allDeps) {
const dependencyName = name.replace(/\//g, '_') // slashes in dep name will mess with file structure
const dependencyName = name
if (!(allDeps[name]).includes('file:')) { // we don't care about intra-repo dependencies
parts.push({
name: dependencyName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ export class NPMDependencyCondensedReport extends DependencyCondensedReport {
}

async getNPMPackageInfo (name: string): Promise<Dependency> {
name = name.replace('_', '/') // we removed slashes for file system reasons but need to add them back here
try {
const res: any = await fetch(`https://registry.npmjs.org/${name}`).then(async res => await res.json())
if (res.error != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ export default function (ruleFile: RuleFile): PIPDependencyParts[] {
const parts: PIPDependencyParts[] = []
if (validPIPRequirementsFile.Check(ruleFile) && ruleFile.fileType === FileTypeEnum.PIP_REQUIREMENTS) {
for (const name in ruleFile.dependencies) {
const dependencyName = name.replace(/\//g, '_') // slashes in dep name will mess with file structure
parts.push({
name: dependencyName,
name: name,
version: removeComparatorsInVersion(ruleFile.dependencies[name].version)
})
}
Expand Down

0 comments on commit 194c8b7

Please sign in to comment.