Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update InSpec Object (ts-inspec-objects) import #3230

Merged
merged 4 commits into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"@mitre/emass_client": "3.10.0",
"@mitre/hdf-converters": "2.11.1",
"@mitre/heimdall-lite": "2.11.1",
"@mitre/inspec-objects": "2.0.0",
"@mitre/inspec-objects": "2.0.1",
"@oclif/core": "^4.0.15",
"@oclif/plugin-help": "^6.0.9",
"@oclif/plugin-plugins": "^5.0.14",
Expand Down
8 changes: 2 additions & 6 deletions src/commands/generate/delta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,9 @@ import {
updateProfileUsingXCCDF,
processXCCDF,
updateControl,
Profile,
Control,
} from '@mitre/inspec-objects'

// eslint-disable-next-line no-warning-comments
// TODO: We shouldn't have to import like this, open issue to clean library up for inspec-objects
// test failed in updating inspec-objects to address high lvl vuln
import Profile from '@mitre/inspec-objects/lib/objects/profile'
import Control from '@mitre/inspec-objects/lib/objects/control'
import path from 'path'
import {createWinstonLogger} from '../../utils/logging'
import fse from 'fs-extra'
Expand Down
24 changes: 2 additions & 22 deletions src/commands/generate/inspec_profile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@ import parser from 'fast-xml-parser'
import {InSpecMetaData, InspecReadme} from '../../types/inspec'
import path from 'path'
import {createWinstonLogger} from '../../utils/logging'
import {processOVAL, processXCCDF} from '@mitre/inspec-objects'
import Profile from '@mitre/inspec-objects/lib/objects/profile'
import {processOVAL, processXCCDF, Profile} from '@mitre/inspec-objects'
import {BaseCommand} from '../../utils/oclif/baseCommand'
import {Logger} from 'winston'
import _ from 'lodash'
import YAML from 'yaml'

export default class InspecProfile extends BaseCommand<typeof InspecProfile> {
static readonly usage =
Expand Down Expand Up @@ -629,25 +627,7 @@ ${contentObj.profileType === 'CIS' ?
}

function generateYaml(profile: Profile, outDir: string, logger: Logger) {
// ----------------------------------------------------------------------
// NOTE: Not using the profile.createInspecYaml() as it does not wrap the
// inspect_version in double quotes (the format is ~>#.#). Use this
// function until ts-object.ts method is fixed

const inspecYmlContent = YAML.stringify({
name: profile.name,
title: profile.title,
maintainer: profile.maintainer,
copyright: profile.copyright,
copyright_email: profile.copyright_email,
license: profile.license,
summary: profile.summary,
description: profile.description,
version: profile.version,
supports: profile.supports,
depends: profile.depends,
inspec_version: YAML.stringify(`${profile.inspec_version}`, {defaultStringType: 'QUOTE_DOUBLE'}),
}) +
const inspecYmlContent = profile.createInspecYaml() +
`

### INPUTS ###
Expand Down
2 changes: 1 addition & 1 deletion src/commands/generate/update_controls4delta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import {readdir} from 'fs/promises'
import {execSync} from 'child_process'
import {Flags} from '@oclif/core'
import {createWinstonLogger} from '../../utils/logging'
import Profile from '@mitre/inspec-objects/lib/objects/profile'
import {
getExistingDescribeFromControl,
processInSpecProfile,
processXCCDF,
Profile,
} from '@mitre/inspec-objects'
import colors from 'colors' // eslint-disable-line no-restricted-imports
import {BaseCommand} from '../../utils/oclif/baseCommand'
Expand Down
Loading