Skip to content

Commit

Permalink
handle output readability better
Browse files Browse the repository at this point in the history
  • Loading branch information
meme112233 committed Aug 5, 2024
1 parent 4c07e73 commit fb8203f
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions libs/hdf-converters/src/msft-secure-score-mapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,21 @@ type ProfileResponse = {
'@odata.context': string;
'@odata.nextLink': string;
value: SecureScoreControlProfile[];
}
};
type SecureScoreResponse = {
'@odata.context': string;
'@odata.nextLink': string;
value: SecureScore[];
}
};

export class MsftSecureScoreMapper extends BaseConverter {
withRaw: boolean;
rawData: {secureScore: SecureScoreResponse, profiles: ProfileResponse}
rawData: {secureScore: SecureScoreResponse; profiles: ProfileResponse};

private getProfiles(controlName: string): SecureScoreControlProfile[] {
return this.rawData.profiles.value.filter((profile) => profile.id === controlName);
return this.rawData.profiles.value.filter(
(profile) => profile.id === controlName
);
}

mappings: MappedTransform<
Expand Down Expand Up @@ -64,7 +66,9 @@ export class MsftSecureScoreMapper extends BaseConverter {
if (titles.length > 0) {
return titles.join('\n');
} else {
return `${data.controlCategory || ''}:${data.controlName || ''}`;
return [data.controlCategory || '', data.controlName || '']
.filter((title) => title)
.join(':');
}
}
},
Expand Down Expand Up @@ -218,10 +222,13 @@ export class MsftSecureScoreMapper extends BaseConverter {
return {
auxiliary_data: [
{
name: 'Microsoft Secure Score',
name: 'Microsoft Secure Score',
data: {
profiles: this.rawData.profiles,
secureScores: _.pick(this.rawData.secureScore, ['@odata.context', '@odata.nextLink'])
secureScores: _.pick(this.rawData.secureScore, [
'@odata.context',
'@odata.nextLink'
])
}
}
],
Expand Down

0 comments on commit fb8203f

Please sign in to comment.