Skip to content

Commit

Permalink
Fix legacy questionnaire
Browse files Browse the repository at this point in the history
Signed-off-by: Marek Aufart <[email protected]>
  • Loading branch information
aufi committed Mar 18, 2024
1 parent bbca57d commit afc2462
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions hack/tool/tackle
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,6 @@ def apiFilePost(url, token, filePath, ignoreErrors=False):
return resp.text

def tackle2path(obj):
if 'assessment' in obj:
return "/hub/pathfinder/%s" % obj.replace("--", "/") # Nested path decoding (e.g. assessments/assessment-risk)
return "/hub/%s" % obj

def loadDump(path, fallback_value = []):
Expand Down Expand Up @@ -244,7 +242,7 @@ def cmdWanted(args, action):

class TackleTool:
# TYPES order matters for import/upload to Tackle2
TYPES = ['tagcategories', 'tags', 'jobfunctions', 'stakeholdergroups', 'stakeholders', 'businessservices', 'identities', 'applications', 'analyses', 'proxies', 'dependencies', 'questionnaires', 'archetypes', 'assessments', 'reviews']
TYPES = ['tagcategories', 'tags', 'jobfunctions', 'stakeholdergroups', 'stakeholders', 'businessservices', 'identities', 'applications', 'proxies', 'dependencies', 'questionnaires', 'archetypes', 'assessments', 'reviews']
NOT_IMPORTED_TYPES = ['taskgroups', 'tasks']
TACKLE2_SEED_TYPES = ['tagcategories', 'tags', 'jobfunctions']

Expand Down Expand Up @@ -303,16 +301,22 @@ class TackleTool:

# Gather Tackle 2 API objects
def dumpTackle2(self):
ensureDataDir(self.dataDir)
for t in self.TYPES:
print("Exporting %s.." % t)
if "identities" in t:
if t == "identities":
dictCollection = apiJSON(self.tackle2Url + "/hub/identities?decrypted=1", self.tackle2Token)
for dictObj in dictCollection:
dictObj['key'] = self.encrypt(dictObj['key'])
dictObj['password'] = self.encrypt(dictObj['password'])
dictObj['settings'] = self.encrypt(dictObj['settings'])
else:
dictCollection = apiJSON(self.tackle2Url + tackle2path(t), self.tackle2Token)

# Remove legacy locked questionnaire from export to not cause conflict in import (should be 1st one)
if t == "questionnaires":
dictCollection = dictCollection[1:]

# Save data locally
saveJSON(os.path.join(self.dataDir, t), dictCollection)

Expand Down Expand Up @@ -527,8 +531,6 @@ if cmdWanted(args, "export"):
# Setup data migration object
tool = TackleTool(args.data_dir, '', '', c['url'], token2, c['encryption_passphase'])

ensureDataDir(self.dataDir)

# Run the export expecting clean destination
print("Exporting Tackle 2 objects into %s (this might take a while..)" % args.data_dir)
tool.dumpTackle2()
Expand Down

0 comments on commit afc2462

Please sign in to comment.