Skip to content

Add Nested Shared Folder (NSF) support to CyberArk PAM import#2233

Open
pvagare-ks wants to merge 4 commits into
KC-1355from
KC-1246-nsf-int
Open

Add Nested Shared Folder (NSF) support to CyberArk PAM import#2233
pvagare-ks wants to merge 4 commits into
KC-1355from
KC-1246-nsf-int

Conversation

@pvagare-ks

Copy link
Copy Markdown
Contributor

Summary

  • Adds --nsf to pam project cyberark-import so CyberArk migrations can create project folders, records and PAM configuration under Nested Shared Folders instead of classic shared folders.

Changes

  • Added pam project cyberark-import <cybeark_tenant> --nsf command for creating nsf folders, pam records and pam config

@pvagare-ks pvagare-ks self-assigned this Jul 20, 2026
"""
from ... import api, vault_extensions
from .nsf_helpers import find_pam_configuration
from .record_loader import iter_accessible_record_uids, load_pam_record

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

move imports at top

rec = load_pam_record(params, uid)
if not rec or getattr(rec, "version", None) != 6:
continue
title = getattr(rec, "title", "") or ""

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We can create separate method for match


def is_matching_title(title: str, base: str) -> bool:
    title = title.casefold()

    if title == base:
        return True

    if not title.startswith(base):
        return False

    return bool(re.fullmatch(r" #\d+", title[len(base):]))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

 if is_matching_title(getattr(record, "title", "") or "", config_base):
        candidates.append(record)
        seen_uids.add(uid)

if not config_rec:
for uid in iter_accessible_record_uids(params):
rec = load_pam_record(params, uid)
if not rec or getattr(rec, "version", None) != 6:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

what if positive condition used

if rec or getattr(rec, "version", None) == 6:
  title = getattr(rec, "title", "") or ""

# wrapper folder(s). Records live inside these (and inside
# their Resources / Users subfolders for the safe-per-folder
# layout).
shared_folder_uids: List[str] = []

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

use list[]

return index

try:
from keepercommander.commands.pam_import.nsf_helpers import get_folder_record_uids

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

import in try?

for ruid in all_record_uids:
rec = vault.KeeperRecord.load(params, ruid)
try:
from keepercommander.commands.pam_import.record_loader import load_pam_record

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

move import at top


root = NestedShareFolderNode()
root.uid = "nsf-root"
root.name = "PAM Environments"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

create constant for "PAM Environments", "CyberArk Migration", "Win_Local" etc

def test_find_classic_wrapper_still_works(self):
from types import SimpleNamespace
from keepercommander.commands.pam_import.cyberark_import import CyberArkPAMCleanupCommand
from keepercommander.subfolder import BaseFolderNode

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

move import at top

"--platform-map", "map.json",
"--state-filter", "active,inactive",
"--no-verify-ssl",
"--nsf",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

use nsf as default and add classic flow as a flag

@adeshmukh-ks adeshmukh-ks left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

if possible change the code to make nsf as default flow and classic folder flow to be on using a flag

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants