@@ -81717,23 +81717,113 @@ var SlackAppUrl;
81717
81717
;// CONCATENATED MODULE: ./src/utils/slack/user-matchers.ts
81718
81718
81719
81719
81720
+ /**
81721
+ * Redacts sensitive information for safe logging
81722
+ * Replaces characters with random alphanumeric chars of matching case
81723
+ * Preserves first and last character, special chars, and word structure
81724
+ */
81725
+ function redact(text) {
81726
+ if (!text) {
81727
+ return '';
81728
+ }
81729
+ // Return very short strings as is
81730
+ if (text.length <= 2) {
81731
+ return text;
81732
+ }
81733
+ // Handle email addresses by splitting at @
81734
+ if (text.includes('@')) {
81735
+ const [localPart, domainPart] = text.split('@');
81736
+ const redactedLocal = redact(localPart);
81737
+ // Redact each part of the domain separately
81738
+ const domainParts = domainPart.split('.');
81739
+ const redactedDomain = domainParts
81740
+ .map((part, index) => {
81741
+ // Preserve common TLDs and very short parts
81742
+ if (part.length <= 2 ||
81743
+ (index === domainParts.length - 1 &&
81744
+ ['com', 'org', 'net', 'io', 'co', 'ai', 'app', 'dev'].includes(part.toLowerCase()))) {
81745
+ return part;
81746
+ }
81747
+ return redactPart(part);
81748
+ })
81749
+ .join('.');
81750
+ return `${redactedLocal}@${redactedDomain}`;
81751
+ }
81752
+ return redactPart(text);
81753
+ }
81754
+ /**
81755
+ * Redacts a single word or part by replacing characters with random
81756
+ * alphanumeric chars of the same case, preserving first and last character
81757
+ */
81758
+ function redactPart(text) {
81759
+ if (text.length <= 2) {
81760
+ return text;
81761
+ }
81762
+ // Keep first and last characters intact
81763
+ const first = text[0];
81764
+ const last = text[text.length - 1];
81765
+ const middle = text.substring(1, text.length - 1);
81766
+ // Replace each middle character with a random one of the same case
81767
+ const redactedMiddle = Array.from(middle)
81768
+ .map((char) => {
81769
+ // Skip non-alphanumeric characters
81770
+ if (!/[a-zA-Z0-9]/.test(char)) {
81771
+ return char;
81772
+ }
81773
+ // Generate substitutions based on character case
81774
+ if (/[a-z]/.test(char)) {
81775
+ return getRandomChar('abcdefghijklmnopqrstuvwxyz');
81776
+ }
81777
+ if (/[A-Z]/.test(char)) {
81778
+ return getRandomChar('ABCDEFGHIJKLMNOPQRSTUVWXYZ');
81779
+ }
81780
+ if (/[0-9]/.test(char)) {
81781
+ return getRandomChar('0123456789');
81782
+ }
81783
+ return char;
81784
+ })
81785
+ .join('');
81786
+ return `${first}${redactedMiddle}${last}`;
81787
+ }
81788
+ /**
81789
+ * Get a random character from a character set
81790
+ */
81791
+ function getRandomChar(charSet) {
81792
+ const randomIndex = Math.floor(Math.random() * charSet.length);
81793
+ return charSet[randomIndex];
81794
+ }
81720
81795
function customMappingMatcher(githubUsername, slackUsername) {
81721
81796
return {
81722
- check: (user) => user.name?.toLowerCase() === slackUsername.toLowerCase() ||
81723
- user.profile?.display_name?.toLowerCase() === slackUsername.toLowerCase() ||
81724
- user.profile?.real_name?.toLowerCase() === slackUsername.toLowerCase(),
81797
+ check: (user) => {
81798
+ const name = user.name?.toLowerCase() ?? '';
81799
+ const displayName = user.profile?.display_name?.toLowerCase() ?? '';
81800
+ const realName = user.profile?.real_name?.toLowerCase() ?? '';
81801
+ const slackNameLower = slackUsername.toLowerCase();
81802
+ return (name.includes(slackNameLower) ||
81803
+ slackNameLower.includes(name) ||
81804
+ displayName.includes(slackNameLower) ||
81805
+ slackNameLower.includes(displayName) ||
81806
+ realName.includes(slackNameLower) ||
81807
+ slackNameLower.includes(realName));
81808
+ },
81725
81809
description: 'custom user mapping',
81726
81810
log: (user) => {
81727
81811
(0,core.debug)(`Match found by custom mapping: GitHub username [${githubUsername}] to Slack username [${slackUsername}] for user [${user.id}]`);
81812
+ (0,core.debug)(`Redacted debug info: GitHub username [${redact(githubUsername)}] to Slack username [${redact(slackUsername)}] matched with user name [${redact(user.name ?? '')}], display_name [${redact(user.profile?.display_name ?? '')}], real_name [${redact(user.profile?.real_name ?? '')}]`);
81728
81813
},
81729
81814
};
81730
81815
}
81731
81816
function displayNameMatcher(username) {
81732
81817
return {
81733
- check: (user) => user.profile?.display_name?.toLowerCase() === username.toLowerCase(),
81818
+ check: (user) => {
81819
+ const displayName = user.profile?.display_name?.toLowerCase() ?? '';
81820
+ const usernameLower = username.toLowerCase();
81821
+ return displayName.includes(usernameLower) || usernameLower.includes(displayName);
81822
+ },
81734
81823
description: 'user.profile.display_name fields',
81735
81824
log: (user) => {
81736
81825
(0,core.debug)(`Match found by username [${username}] matching Slack displayName [${user.profile?.display_name}]`);
81826
+ (0,core.debug)(`Redacted debug info: username [${redact(username)}] matched with display_name [${redact(user.profile?.display_name ?? '')}]`);
81737
81827
},
81738
81828
};
81739
81829
}
@@ -81745,6 +81835,7 @@ function emailContainsMatcher(username) {
81745
81835
description: 'user.profile.email contains check',
81746
81836
log: (user) => {
81747
81837
(0,core.debug)(`Match found by username [${username}] contained in Slack email [${user.profile?.email}]`);
81838
+ (0,core.debug)(`Redacted debug info: username [${redact(username)}] matched with email [${redact(user.profile?.email ?? '')}]`);
81748
81839
},
81749
81840
};
81750
81841
}
@@ -81754,15 +81845,21 @@ function emailMatcher(email) {
81754
81845
description: 'user.profile.email fields',
81755
81846
log: (user) => {
81756
81847
(0,core.debug)(`Match found by email [${email}] with Slack email [${user.profile?.email}]`);
81848
+ (0,core.debug)(`Redacted debug info: email [${redact(email)}] matched with Slack email [${redact(user.profile?.email ?? '')}]`);
81757
81849
},
81758
81850
};
81759
81851
}
81760
81852
function realNameMatcher(username) {
81761
81853
return {
81762
- check: (user) => user.profile?.real_name?.toLowerCase() === username.toLowerCase(),
81854
+ check: (user) => {
81855
+ const realName = user.profile?.real_name?.toLowerCase() ?? '';
81856
+ const usernameLower = username.toLowerCase();
81857
+ return realName.includes(usernameLower) || usernameLower.includes(realName);
81858
+ },
81763
81859
description: 'user.profile.real_name fields',
81764
81860
log: (user) => {
81765
81861
(0,core.debug)(`Match found by username [${username}] matching Slack realName [${user.profile?.real_name}]`);
81862
+ (0,core.debug)(`Redacted debug info: username [${redact(username)}] matched with real_name [${redact(user.profile?.real_name ?? '')}]`);
81766
81863
},
81767
81864
};
81768
81865
}
@@ -81772,6 +81869,7 @@ function userIdMatcher(userId) {
81772
81869
description: 'user.id fields',
81773
81870
log: (user) => {
81774
81871
(0,core.debug)(`Match found by userId [${userId}] with Slack userId [${user.id}]`);
81872
+ (0,core.debug)(`Redacted debug info: userId matched with Slack userId [${redact(user.id ?? '')}]`);
81775
81873
},
81776
81874
};
81777
81875
}
@@ -81782,6 +81880,7 @@ const createUserMatchers = ({ email, userId, userMappings = [], username }) => {
81782
81880
const matchingMappings = userMappings.filter((mapping) => mapping.githubUsername === username);
81783
81881
if (matchingMappings.length > 0) {
81784
81882
(0,core.debug)(`Found [${matchingMappings.length}] custom mappings for GitHub username [${username}]`);
81883
+ (0,core.debug)(`Redacted debug info: Found [${matchingMappings.length}] custom mappings for GitHub username [${redact(username)}]`);
81785
81884
// Add a matcher for each mapping
81786
81885
matchingMappings.forEach((mapping) => {
81787
81886
matchers.push(customMappingMatcher(username, mapping.slackUsername));
@@ -81804,25 +81903,35 @@ const createUserMatchers = ({ email, userId, userMappings = [], username }) => {
81804
81903
};
81805
81904
const logFailedMatches = ({ email, userId, userMappings = [], username }, usersCount) => {
81806
81905
console.log(`No user match found for [${username}] after checking against [${usersCount}] Slack ${(0,src.plural)('user', usersCount)}`);
81906
+ // Redacted version
81907
+ console.log(`Redacted debug info: No user match found for [${redact(username ?? '')}] after checking against [${usersCount}] Slack ${(0,src.plural)('user', usersCount)}`);
81807
81908
// Log mapping failures
81808
81909
if (username && userMappings.length > 0) {
81809
81910
const matchingMappings = userMappings.filter((mapping) => mapping.githubUsername === username);
81810
81911
if (matchingMappings.length > 0) {
81811
81912
(0,core.debug)(`WARNING: Custom mappings for GitHub username [${username}] were defined but no matching Slack users were found:`);
81913
+ (0,core.debug)(`Redacted debug info: WARNING: Custom mappings for GitHub username [${redact(username)}] were defined but no matching Slack users were found:`);
81812
81914
// Show each mapping that failed
81813
81915
matchingMappings.forEach((mapping) => {
81814
81916
(0,core.debug)(` - Mapped to Slack username [${mapping.slackUsername}] but no Slack user with this name/display_name/real_name was found`);
81917
+ (0,core.debug)(` - Redacted debug info: Mapped to Slack username [${redact(mapping.slackUsername)}] but no Slack user with this name/display_name/real_name was found`);
81815
81918
});
81816
81919
(0,core.debug)(`Attempted to fall back to standard matching methods`);
81817
81920
}
81818
81921
}
81819
81922
// Log standard matchers that were tried
81820
- if (userId)
81923
+ if (userId) {
81821
81924
(0,core.debug)(`Tried to match userId [${userId}] against Slack user.id fields`);
81822
- if (email)
81925
+ (0,core.debug)(`Redacted debug info: Tried to match userId [${redact(userId)}] against Slack user.id fields`);
81926
+ }
81927
+ if (email) {
81823
81928
(0,core.debug)(`Tried to match email [${email}] against Slack user.profile.email fields`);
81824
- if (username)
81929
+ (0,core.debug)(`Redacted debug info: Tried to match email [${redact(email)}] against Slack user.profile.email fields`);
81930
+ }
81931
+ if (username) {
81825
81932
(0,core.debug)(`Tried to match username [${username}] against Slack user.profile.email (contains), display_name and real_name fields`);
81933
+ (0,core.debug)(`Redacted debug info: Tried to match username [${redact(username)}] against Slack user.profile.email (contains), display_name and real_name fields`);
81934
+ }
81826
81935
(0,core.debug)(`Since no Slack user match found, unable to @mention user or use their profile image`);
81827
81936
};
81828
81937
@@ -90631,7 +90740,7 @@ module.exports = {"version":"3.17.0"};
90631
90740
/***/ 8330:
90632
90741
/***/ ((module) => {
90633
90742
90634
- module.exports = /*#__PURE__*/JSON.parse('{"UU":"@krauters/github-notifier","rE":"1.3.2 ","TB":"https://buymeacoffee.com/coltenkrauter"}');
90743
+ module.exports = /*#__PURE__*/JSON.parse('{"UU":"@krauters/github-notifier","rE":"1.3.3 ","TB":"https://buymeacoffee.com/coltenkrauter"}');
90635
90744
90636
90745
/***/ })
90637
90746
0 commit comments