almenscorner / IntuneCD

Tool to backup, update and document configurations in Intune
MIT License
289 stars 38 forks source link

[BUG] MobileApp Create By... being created without --audit #195

Closed Wob76 closed 6 months ago

Wob76 commented 6 months ago

Describe the bug It seems the changed to 2.3.1 are pushing git commits for Applications even when --audit is not being used.

To Reproduce I use an existing post audit process I had in place before --audit was added, I prefer to bundle changes per user to reduce the number of changes, and I lookup Display Name rather than UPN as it is easier to read in my environment.

As such I have not added --audit in my IntuneCD-startbackup command.

As of the 2.3.1 update I am seeing 'MobileApp Create by {UPN}..." commits in my history.

I am not seeing commits for anything other than Applications.

Expected behavior No git commits should take place unless --audit is used.

Log Data

[Mon Apr  8 14:23:08 2024] - Backing up Application: ****
Mon Apr  8 14:23:08 2024 [INFO] [get_scope_tags_name] - Checking if scope tags are in the data.
Mon Apr  8 14:23:08 2024 [INFO] [get_scope_tags_name] - Scope tags are in the data.
Mon Apr  8 14:23:08 2024 [INFO] [get_scope_tags_name] - Scope tags: ['Default', ****]
Mon Apr  8 14:23:08 2024 [INFO] [get_scope_tags_name] - Checking if scope tags are in the data.
Mon Apr  8 14:23:08 2024 [INFO] [process_audit_data] - Processing audit data for /home/vsts/work/1/s/****/Applications/iOS/****.json in path /home/vsts/work/1/s/****/Applications/iOS/.
Mon Apr  8 14:23:08 2024 [INFO] [_check_if_git_repo] - Path is set to /home/vsts/work/1/s/****/Applications/iOS/ and file is set to /home/vsts/work/1/s/****/Applications/iOS/****.json.
Mon Apr  8 14:23:08 2024 [INFO] [_check_if_git_repo] - Running command git command ['git', '-C', '/home/vsts/work/1/s/****/Applications/iOS/', 'rev-parse', '--is-inside-work-tree'] to determine if the path is a git repo.
Mon Apr  8 14:23:08 2024 [INFO] [_check_if_git_repo] - Path is a git repo.
Mon Apr  8 14:23:08 2024 [INFO] [_git_installed] - Running command git --version to check if git is installed.
Mon Apr  8 14:23:08 2024 [INFO] [_git_installed] - Git is installed.
Mon Apr  8 14:23:08 2024 [INFO] [_configure_git] - Running command ['git', '-C', '/home/vsts/work/1/s/****/Applications/iOS/', 'config', '--local', 'user.email', '{UPN}'] to configure git user email to {UPN}.
Mon Apr  8 14:23:08 2024 [INFO] [_configure_git] - Running command ['git', '-C', '/home/vsts/work/1/s/****/Applications/iOS/', 'config', '--local', 'user.name', '{UPN}'] to configure git user name.
Mon Apr  8 14:23:08 2024 [INFO] [_git_check_modified] - Running command ['git', '-C', '/home/vsts/work/1/s/****/Applications/iOS/', 'diff', '--name-only', "/home/vsts/work/1/s/****/Applications/iOS/****.json"] to check if /home/vsts/work/1/s/****/Applications/iOS/****.json has been modified.
Mon Apr  8 14:23:08 2024 [INFO] [_git_commit_changes] - Running command ['git', '-C', '/home/vsts/work/1/s/****/Applications/iOS/', 'add', "/home/vsts/work/1/s/****/Applications/iOS/****.json"] to add /home/vsts/work/1/s/****/Applications/iOS/****.json to the git repo.
Mon Apr  8 14:23:08 2024 [INFO] [_git_commit_changes] - Committing the changes to /home/vsts/work/1/s/****/Applications/iOS/****.json.
Mon Apr  8 14:23:08 2024 [INFO] [_git_commit_changes] - Commit was successful.
Mon Apr  8 14:23:08 2024 [INFO] [process_audit_data] - Audit data has been processed.

Run type (please complete the following information):

            IntuneCD-startbackup \
                -v \
                --mode=1 \
                --output=json \
                --path="$(Build.SourcesDirectory)/$(BACKUP_FOLDER)" \
                --exclude VPPusedLicenseCount \
                --exclude GPlaySyncTime \
                --exclude CompliancePartnerHeartbeat \
                --append-id

Additional context Add any other context about the problem here.

almenscorner commented 6 months ago

Audit was indeed being processed for apps even when the argument was not used, this was because the data is being pre-fetched in the module. I've added an additional check in the module if the argument is set before getting the data.

Try pip3 install IntuneCD==2.3.2b1 and verify that no audit data is included.

Wob76 commented 6 months ago

Looking good, I have updated my test pipeline to use 2.3.2b1 and no extra commits.