Skip to content
This repository has been archived by the owner on Aug 8, 2024. It is now read-only.

Jira Enhancement 5.1.1 #225

Merged
merged 13 commits into from
Jul 22, 2024
Merged

Jira Enhancement 5.1.1 #225

merged 13 commits into from
Jul 22, 2024

Conversation

poornima-metron
Copy link
Collaborator

Description

Thank you for contributing to a JupiterOne integration!

Please include a summary of the change and which issue is fixed. Please also
include relevant motivation and context. List any dependencies that are required
for this change.

Summary

Type of change

Please leave any irrelevant options unchecked.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to
    not work as expected)
  • This change requires a documentation update

Checklist

General Development Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Integration Development Checklist:

Please leave any irrelevant options unchecked.

  • I have checked for additional permissions required to call any new API
    endpoints, and have documented any additional permissions in
    jupiterone.md, where necessary.
  • My changes properly paginate the target service provider's API
  • My changes properly handle rate limiting of the target service provider's
    API
  • My new integration step is instrumented to execute in the correct order
    using dependsOn
  • I have referred to the
    JupiterOne data model
    to ensure that any new entities/relationships, and relevant properties,
    match the recommended model for this class of data
  • I have updated the CHANGELOG.md file to describe my changes
  • When changes include modifications to existing graph data ingestion, I've
    reviewed all existing managed questions referencing the entities,
    relationships, and their property names, to ensure those questions still
    function with my changes.

@poornima-metron poornima-metron requested a review from a team as a code owner June 27, 2024 16:57
src/config.ts Outdated
Comment on lines 75 to 79
complexCustomFields: {
type: 'json',
mask: false,
optional: true,
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's not use a different config field for this, should be handled within the existing "customFields" field

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed complexCustomFields from config

Comment on lines 128 to 152
complexCustomFieldsToInclude.forEach((path) => {
const [baseFieldId, ...nestedPathParts] = path.split('.');
if (issue.fields[baseFieldId] !== undefined) {
const nestedPath = nestedPathParts.join('.');
const fieldValue = getNestedValue(issue.fields[baseFieldId], nestedPath);
if (fieldValue !== undefined) {
if (fieldsById && fieldsById[baseFieldId]) {
const baseFieldName = camelCase(fieldsById[baseFieldId].name);
const formattedPathParts = nestedPathParts.map((part) => {
const match = part.match(/^(\w+)(?:\[(\d+)\])?$/);
if (match) {
const [, key, index] = match;
if (index !== undefined) {
return `${camelCase(key)}${index}`;
}
return camelCase(key);
}
return camelCase(part);
});
const formattedPath = [baseFieldName, ...formattedPathParts].join('');
setFlatNestedValue(customFields, formattedPath, fieldValue);
}
}
}
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This implementation can be simplified with lodash get method and the field name formatting can also be simplified:

  for (const path of complexCustomFieldsToInclude) {
    const [baseFieldId, ...rest] = path.split('.');
    const nestedPath = rest.join('.');
    if (!issue.fields[baseFieldId]) {
      continue;
    }
    const extractedValue = get(issue.fields[baseFieldId], nestedPath);
    if (!extractedValue) {
      continue;
    }
    const baseFieldName = camelCase(fieldsById[baseFieldId].name);
    const fieldName = nestedPath.split(/[\.\[\]]+/).map(camelCase).join('');
    customFields[`${baseFieldName}${fieldName}`] = extractedValue;
  }

Also this should be adapted to be inside the loop in line 105 because all custom fields should come in the customFields config field. So you can verify first if it's a complex field and execute this logic, if it's not execute the logic for simple fields as it is.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this makes sense, moved the suggested logic inside the loop and verifying if its a complex field or simple field

Comment on lines 82 to 90
logger.info(
{
complexCustomFields: config.complexCustomFields,
allFieldIdsAndNames: Object.values(fieldsById).map(
(field) => `${field.id}: ${field.name ?? 'undefined field name'}`,
),
},
'Complex custom fields to ingest.',
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not necessary as these will be part of customFields config

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed the log

@RonaldEAM RonaldEAM merged commit 5aeaca4 into main Jul 22, 2024
8 checks passed
@RonaldEAM RonaldEAM deleted the Jira-enhancement branch July 22, 2024 15:15
@j1-internal-automation
Copy link
Collaborator

🚀 PR was released in v5.2.0 🚀

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants