@unveil/identity 1.2.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +3 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -18,6 +18,7 @@ type IdentifyOptions = {
|
|
|
18
18
|
reposCount: number;
|
|
19
19
|
accountName: string;
|
|
20
20
|
events: GitHubEvent[];
|
|
21
|
+
excludeRepos?: string[];
|
|
21
22
|
};
|
|
22
23
|
type IdentityClassification = "organic" | "mixed" | "automation";
|
|
23
24
|
type IdentifyResult = {
|
|
@@ -35,7 +36,8 @@ declare function identify({
|
|
|
35
36
|
createdAt,
|
|
36
37
|
reposCount,
|
|
37
38
|
accountName,
|
|
38
|
-
events
|
|
39
|
+
events,
|
|
40
|
+
excludeRepos
|
|
39
41
|
}: IdentifyOptions): IdentifyResult;
|
|
40
42
|
//#endregion
|
|
41
43
|
//#region src/classification.d.ts
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),s=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},c=(n,r,a)=>(a=n==null?{}:e(i(n)),s(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));function l(e){if(e.length===0)return 0;let t=e.reduce((e,t)=>e+t,0);if(t===0)return 0;let n=0;for(let r of e)if(r>0){let e=r/t;n-=e*Math.log2(e)}return n}function u(e){return e.length<=1?0:l(e)/Math.log2(e.length)}const d={THRESHOLD_HUMAN:70,THRESHOLD_SUSPICIOUS:50,AGE_NEW_ACCOUNT:30,AGE_YOUNG_ACCOUNT:90,POINTS_NEW_ACCOUNT:20,POINTS_YOUNG_ACCOUNT:10,POINTS_NO_IDENTITY:15,FOLLOW_RATIO_FOLLOWING_MIN:50,FOLLOW_RATIO_FOLLOWERS_MAX:5,POINTS_FOLLOW_RATIO:15,POINTS_ZERO_FOLLOWERS:10,MIN_EVENTS_FOR_ANALYSIS:10,FORKS_EXTREME:8,FORKS_HIGH:5,FORKS_SURGE_SEVERE:20,FORKS_SURGE_EXTREME_HIGH:35,FORK_SURGE_WINDOW_HOURS:24,POINTS_FORK_SURGE:51,POINTS_FORK_SURGE_SEVERE:70,POINTS_FORK_SURGE_EXTREME_HIGH:85,POINTS_MULTIPLE_FORKS:26,FORKS_SURGE_48H:18,FORKS_SURGE_72H:25,POINTS_FORK_SURGE_48H:65,POINTS_FORK_SURGE_72H:75,FORKS_PER_DAY_HIGH:8,POINTS_FORKS_PER_DAY_HIGH:55,CONSECUTIVE_FORK_DAYS:6,POINTS_CONSECUTIVE_FORK_DAYS:40,FORK_COMBINED_ACTIVITY_MIN:12,FORK_COMBINED_BRANCHES:6,FORK_COMBINED_PRS:8,POINTS_FORK_COMBINED_ACTIVITY:60,FORK_REPO_DIVERSITY_HIGH:15,POINTS_FORK_DIVERSITY:45,HOURS_PER_DAY_INHUMAN:16,CONSECUTIVE_INHUMAN_DAYS_EXTREME:3,FREQUENT_MARATHON_DAYS:5,POINTS_NONSTOP_ACTIVITY:40,POINTS_FREQUENT_MARATHON:25,REPO_SPREAD_EXTREME:30,REPO_SPREAD_HIGH:20,POINTS_EXTREME_REPO_SPREAD_YOUNG:30,POINTS_WIDE_REPO_SPREAD_YOUNG:15,PRS_TODAY_EXTREME:15,PRS_WEEK_HIGH:20,POINTS_PR_BURST:20,POINTS_HIGH_PR_FREQUENCY:15,PRS_DAY_EXTREME:30,POINTS_PRS_DAY_EXTREME:45,PRS_WEEK_EXTREME:100,POINTS_PRS_WEEK_EXTREME:50,PRS_WEEK_VERY_HIGH:50,POINTS_PRS_WEEK_VERY_HIGH:40,PRS_SPAM_VOLUME:50,REPOS_SPAM_SPREAD:15,POINTS_PR_SPAM_COMBINED:45,PRS_SPAM_DENSITY_PER_WEEK:15,PRS_SPAM_ROLLING_30DAYS:60,POINTS_PR_SPAM_DISTRIBUTED:45,EXTERNAL_PRS_MIN:15,PERSONAL_REPOS_LOW:5,POINTS_PR_ONLY_CONTRIBUTOR:20,FOREIGN_RATIO_FULL:1,FOREIGN_RATIO_HIGH:.95,PERSONAL_REPOS_NONE:3,POINTS_NO_PERSONAL_ACTIVITY:30,POINTS_EXTERNAL_FOCUS:20,ZERO_REPOS_MIN_EVENTS:20,POINTS_ZERO_REPOS_ACTIVE:20,ACTIVITY_DENSITY_HIGH:8,ACTIVITY_DENSITY_EXTREME:15,POINTS_HIGH_ACTIVITY_DENSITY:15,POINTS_EXTREME_ACTIVITY_DENSITY:25,HOURLY_ACTIVITY_HIGH:50,HOURLY_ACTIVITY_EXTREME:100,TIGHT_COMMIT_SECONDS:600,TIGHT_COMMIT_THRESHOLD:3,POINTS_TIGHT_BURST:25,CREATE_EVENTS_MIN:5,CREATE_BURST_EXTREME:16,CREATE_BURST_HIGH:8,POINTS_CREATE_BURST_EXTREME:35,POINTS_CREATE_BURST_HIGH:25,HOURS_ACTIVE_EXTREME:21,HOURS_ACTIVE_EXTREME_ESTABLISHED:23,EVENTS_PER_HOUR_MIN:2,POINTS_24_7_ACTIVITY:25,AGE_ESTABLISHED_ACCOUNT:1e3,EVENT_TYPE_DIVERSITY_MIN:2,POINTS_LOW_DIVERSITY:20,ISSUE_COMMENT_SPAM_WINDOW_MINUTES:2,ISSUE_COMMENT_SPRAY_EXTREME:15,ISSUE_COMMENT_SPRAY_HIGH:10,ISSUE_COMMENT_MIN_FOR_SPRAY:10,POINTS_ISSUE_COMMENT_SPRAY_EXTREME:40,POINTS_ISSUE_COMMENT_SPRAY_HIGH:30,PR_COMMENT_SPAM_WINDOW_MINUTES:2,PR_COMMENT_SPRAY_EXTREME:12,PR_COMMENT_SPRAY_HIGH:8,PR_COMMENT_MIN_FOR_SPRAY:8,POINTS_PR_COMMENT_SPRAY_EXTREME:38,POINTS_PR_COMMENT_SPRAY_HIGH:28,BRANCH_PR_TIME_WINDOW_SECONDS:90,BRANCH_PR_PATTERN_MIN_PAIRS:8,BRANCH_PR_PATTERN_MIN_PAIRS_ESTABLISHED:15,BRANCH_PR_PATTERN_RATIO_MIN:.65,BRANCH_PR_PATTERN_RATIO_MIN_ESTABLISHED:.8,BRANCH_PR_COUNT_RATIO_MIN:.65,POINTS_BRANCH_PR_AUTOMATION:35};var f=o(((e,t)=>{(function(n,r){typeof e==`object`&&t!==void 0?t.exports=r():typeof define==`function`&&define.amd?define(r):(n=typeof globalThis<`u`?globalThis:n||self).dayjs=r()})(e,(function(){var e=1e3,t=6e4,n=36e5,r=`millisecond`,i=`second`,a=`minute`,o=`hour`,s=`day`,c=`week`,l=`month`,u=`quarter`,d=`year`,f=`date`,p=`Invalid Date`,m=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,h=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,g={name:`en`,weekdays:`Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday`.split(`_`),months:`January_February_March_April_May_June_July_August_September_October_November_December`.split(`_`),ordinal:function(e){var t=[`th`,`st`,`nd`,`rd`],n=e%100;return`[`+e+(t[(n-20)%10]||t[n]||t[0])+`]`}},_=function(e,t,n){var r=String(e);return!r||r.length>=t?e:``+Array(t+1-r.length).join(n)+e},v={s:_,z:function(e){var t=-e.utcOffset(),n=Math.abs(t),r=Math.floor(n/60),i=n%60;return(t<=0?`+`:`-`)+_(r,2,`0`)+`:`+_(i,2,`0`)},m:function e(t,n){if(t.date()<n.date())return-e(n,t);var r=12*(n.year()-t.year())+(n.month()-t.month()),i=t.clone().add(r,l),a=n-i<0,o=t.clone().add(r+(a?-1:1),l);return+(-(r+(n-i)/(a?i-o:o-i))||0)},a:function(e){return e<0?Math.ceil(e)||0:Math.floor(e)},p:function(e){return{M:l,y:d,w:c,d:s,D:f,h:o,m:a,s:i,ms:r,Q:u}[e]||String(e||``).toLowerCase().replace(/s$/,``)},u:function(e){return e===void 0}},y=`en`,b={};b[y]=g;var x=`$isDayjsObject`,S=function(e){return e instanceof E||!(!e||!e[x])},C=function e(t,n,r){var i;if(!t)return y;if(typeof t==`string`){var a=t.toLowerCase();b[a]&&(i=a),n&&(b[a]=n,i=a);var o=t.split(`-`);if(!i&&o.length>1)return e(o[0])}else{var s=t.name;b[s]=t,i=s}return!r&&i&&(y=i),i||!r&&y},w=function(e,t){if(S(e))return e.clone();var n=typeof t==`object`?t:{};return n.date=e,n.args=arguments,new E(n)},T=v;T.l=C,T.i=S,T.w=function(e,t){return w(e,{locale:t.$L,utc:t.$u,x:t.$x,$offset:t.$offset})};var E=function(){function g(e){this.$L=C(e.locale,null,!0),this.parse(e),this.$x=this.$x||e.x||{},this[x]=!0}var _=g.prototype;return _.parse=function(e){this.$d=function(e){var t=e.date,n=e.utc;if(t===null)return new Date(NaN);if(T.u(t))return new Date;if(t instanceof Date)return new Date(t);if(typeof t==`string`&&!/Z$/i.test(t)){var r=t.match(m);if(r){var i=r[2]-1||0,a=(r[7]||`0`).substring(0,3);return n?new Date(Date.UTC(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,a)):new Date(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,a)}}return new Date(t)}(e),this.init()},_.init=function(){var e=this.$d;this.$y=e.getFullYear(),this.$M=e.getMonth(),this.$D=e.getDate(),this.$W=e.getDay(),this.$H=e.getHours(),this.$m=e.getMinutes(),this.$s=e.getSeconds(),this.$ms=e.getMilliseconds()},_.$utils=function(){return T},_.isValid=function(){return this.$d.toString()!==p},_.isSame=function(e,t){var n=w(e);return this.startOf(t)<=n&&n<=this.endOf(t)},_.isAfter=function(e,t){return w(e)<this.startOf(t)},_.isBefore=function(e,t){return this.endOf(t)<w(e)},_.$g=function(e,t,n){return T.u(e)?this[t]:this.set(n,e)},_.unix=function(){return Math.floor(this.valueOf()/1e3)},_.valueOf=function(){return this.$d.getTime()},_.startOf=function(e,t){var n=this,r=!!T.u(t)||t,u=T.p(e),p=function(e,t){var i=T.w(n.$u?Date.UTC(n.$y,t,e):new Date(n.$y,t,e),n);return r?i:i.endOf(s)},m=function(e,t){return T.w(n.toDate()[e].apply(n.toDate(`s`),(r?[0,0,0,0]:[23,59,59,999]).slice(t)),n)},h=this.$W,g=this.$M,_=this.$D,v=`set`+(this.$u?`UTC`:``);switch(u){case d:return r?p(1,0):p(31,11);case l:return r?p(1,g):p(0,g+1);case c:var y=this.$locale().weekStart||0,b=(h<y?h+7:h)-y;return p(r?_-b:_+(6-b),g);case s:case f:return m(v+`Hours`,0);case o:return m(v+`Minutes`,1);case a:return m(v+`Seconds`,2);case i:return m(v+`Milliseconds`,3);default:return this.clone()}},_.endOf=function(e){return this.startOf(e,!1)},_.$set=function(e,t){var n,c=T.p(e),u=`set`+(this.$u?`UTC`:``),p=(n={},n[s]=u+`Date`,n[f]=u+`Date`,n[l]=u+`Month`,n[d]=u+`FullYear`,n[o]=u+`Hours`,n[a]=u+`Minutes`,n[i]=u+`Seconds`,n[r]=u+`Milliseconds`,n)[c],m=c===s?this.$D+(t-this.$W):t;if(c===l||c===d){var h=this.clone().set(f,1);h.$d[p](m),h.init(),this.$d=h.set(f,Math.min(this.$D,h.daysInMonth())).$d}else p&&this.$d[p](m);return this.init(),this},_.set=function(e,t){return this.clone().$set(e,t)},_.get=function(e){return this[T.p(e)]()},_.add=function(r,u){var f,p=this;r=Number(r);var m=T.p(u),h=function(e){var t=w(p);return T.w(t.date(t.date()+Math.round(e*r)),p)};if(m===l)return this.set(l,this.$M+r);if(m===d)return this.set(d,this.$y+r);if(m===s)return h(1);if(m===c)return h(7);var g=(f={},f[a]=t,f[o]=n,f[i]=e,f)[m]||1,_=this.$d.getTime()+r*g;return T.w(_,this)},_.subtract=function(e,t){return this.add(-1*e,t)},_.format=function(e){var t=this,n=this.$locale();if(!this.isValid())return n.invalidDate||p;var r=e||`YYYY-MM-DDTHH:mm:ssZ`,i=T.z(this),a=this.$H,o=this.$m,s=this.$M,c=n.weekdays,l=n.months,u=n.meridiem,d=function(e,n,i,a){return e&&(e[n]||e(t,r))||i[n].slice(0,a)},f=function(e){return T.s(a%12||12,e,`0`)},m=u||function(e,t,n){var r=e<12?`AM`:`PM`;return n?r.toLowerCase():r};return r.replace(h,(function(e,r){return r||function(e){switch(e){case`YY`:return String(t.$y).slice(-2);case`YYYY`:return T.s(t.$y,4,`0`);case`M`:return s+1;case`MM`:return T.s(s+1,2,`0`);case`MMM`:return d(n.monthsShort,s,l,3);case`MMMM`:return d(l,s);case`D`:return t.$D;case`DD`:return T.s(t.$D,2,`0`);case`d`:return String(t.$W);case`dd`:return d(n.weekdaysMin,t.$W,c,2);case`ddd`:return d(n.weekdaysShort,t.$W,c,3);case`dddd`:return c[t.$W];case`H`:return String(a);case`HH`:return T.s(a,2,`0`);case`h`:return f(1);case`hh`:return f(2);case`a`:return m(a,o,!0);case`A`:return m(a,o,!1);case`m`:return String(o);case`mm`:return T.s(o,2,`0`);case`s`:return String(t.$s);case`ss`:return T.s(t.$s,2,`0`);case`SSS`:return T.s(t.$ms,3,`0`);case`Z`:return i}return null}(e)||i.replace(`:`,``)}))},_.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},_.diff=function(r,f,p){var m,h=this,g=T.p(f),_=w(r),v=(_.utcOffset()-this.utcOffset())*t,y=this-_,b=function(){return T.m(h,_)};switch(g){case d:m=b()/12;break;case l:m=b();break;case u:m=b()/3;break;case c:m=(y-v)/6048e5;break;case s:m=(y-v)/864e5;break;case o:m=y/n;break;case a:m=y/t;break;case i:m=y/e;break;default:m=y}return p?m:T.a(m)},_.daysInMonth=function(){return this.endOf(l).$D},_.$locale=function(){return b[this.$L]},_.locale=function(e,t){if(!e)return this.$L;var n=this.clone(),r=C(e,t,!0);return r&&(n.$L=r),n},_.clone=function(){return T.w(this.$d,this)},_.toDate=function(){return new Date(this.valueOf())},_.toJSON=function(){return this.isValid()?this.toISOString():null},_.toISOString=function(){return this.$d.toISOString()},_.toString=function(){return this.$d.toUTCString()},g}(),D=E.prototype;return w.prototype=D,[[`$ms`,r],[`$s`,i],[`$m`,a],[`$H`,o],[`$W`,s],[`$M`,l],[`$y`,d],[`$D`,f]].forEach((function(e){D[e[1]]=function(t){return this.$g(t,e[0],e[1])}})),w.extend=function(e,t){return e.$i||=(e(t,E,w),!0),w},w.locale=C,w.isDayjs=S,w.unix=function(e){return w(1e3*e)},w.en=b[y],w.Ls=b,w.p={},w}))})),p=o(((e,t)=>{(function(n,r){typeof e==`object`&&t!==void 0?t.exports=r():typeof define==`function`&&define.amd?define(r):(n=typeof globalThis<`u`?globalThis:n||self).dayjs_plugin_minMax=r()})(e,(function(){return function(e,t,n){var r=function(e,t){if(!t||!t.length||t.length===1&&!t[0]||t.length===1&&Array.isArray(t[0])&&!t[0].length)return null;var n;t.length===1&&t[0].length>0&&(t=t[0]),n=(t=t.filter((function(e){return e})))[0];for(var r=1;r<t.length;r+=1)t[r].isValid()&&!t[r][e](n)||(n=t[r]);return n};n.max=function(){return r(`isAfter`,[].slice.call(arguments,0))},n.min=function(){return r(`isBefore`,[].slice.call(arguments,0))}}}))})),m=o(((e,t)=>{(function(n,r){typeof e==`object`&&t!==void 0?t.exports=r():typeof define==`function`&&define.amd?define(r):(n=typeof globalThis<`u`?globalThis:n||self).dayjs_plugin_utc=r()})(e,(function(){var e=`minute`,t=/[+-]\d\d(?::?\d\d)?/g,n=/([+-]|\d\d)/g;return function(r,i,a){var o=i.prototype;a.utc=function(e){return new i({date:e,utc:!0,args:arguments})},o.utc=function(t){var n=a(this.toDate(),{locale:this.$L,utc:!0});return t?n.add(this.utcOffset(),e):n},o.local=function(){return a(this.toDate(),{locale:this.$L,utc:!1})};var s=o.parse;o.parse=function(e){e.utc&&(this.$u=!0),this.$utils().u(e.$offset)||(this.$offset=e.$offset),s.call(this,e)};var c=o.init;o.init=function(){if(this.$u){var e=this.$d;this.$y=e.getUTCFullYear(),this.$M=e.getUTCMonth(),this.$D=e.getUTCDate(),this.$W=e.getUTCDay(),this.$H=e.getUTCHours(),this.$m=e.getUTCMinutes(),this.$s=e.getUTCSeconds(),this.$ms=e.getUTCMilliseconds()}else c.call(this)};var l=o.utcOffset;o.utcOffset=function(r,i){var a=this.$utils().u;if(a(r))return this.$u?0:a(this.$offset)?l.call(this):this.$offset;if(typeof r==`string`&&(r=function(e){e===void 0&&(e=``);var r=e.match(t);if(!r)return null;var i=(``+r[0]).match(n)||[`-`,0,0],a=i[0],o=60*i[1]+ +i[2];return o===0?0:a===`+`?o:-o}(r),r===null))return this;var o=Math.abs(r)<=16?60*r:r;if(o===0)return this.utc(i);var s=this.clone();if(i)return s.$offset=o,s.$u=!1,s;var c=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();return(s=this.local().add(o+c,e)).$offset=o,s.$x.$localOffset=c,s};var u=o.format;o.format=function(e){var t=e||(this.$u?`YYYY-MM-DDTHH:mm:ss[Z]`:``);return u.call(this,t)},o.valueOf=function(){var e=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*e},o.isUTC=function(){return!!this.$u},o.toISOString=function(){return this.toDate().toISOString()},o.toString=function(){return this.toDate().toUTCString()};var d=o.toDate;o.toDate=function(e){return e===`s`&&this.$offset?a(this.format(`YYYY-MM-DD HH:mm:ss:SSS`)).toDate():d.call(this)};var f=o.diff;o.diff=function(e,t,n){if(e&&this.$u===e.$u)return f.call(this,e,t,n);var r=this.local(),i=a(e).local();return f.call(r,i,t,n)}}}))})),h=c(f(),1),g=c(p(),1),_=c(m(),1);h.default.extend(g.default),h.default.extend(_.default);function v({createdAt:e,reposCount:t,accountName:n,events:r}){let i=[],a=(0,h.default)().diff(e,`days`);a<d.AGE_NEW_ACCOUNT?i.push({label:`Recently created`,points:d.POINTS_NEW_ACCOUNT,detail:`Account is ${a} days old`}):a<d.AGE_YOUNG_ACCOUNT&&i.push({label:`Young account`,points:d.POINTS_YOUNG_ACCOUNT,detail:`Account is ${a} days old`});let o=r.filter(e=>{let t=e.repo?.name?.split(`/`)[0]?.toLowerCase();return t&&t!==n.toLowerCase()}),s=t===0&&o.length===r.length;s&&r.length>=d.ZERO_REPOS_MIN_EVENTS&&i.push({label:`Only active on other people's repos`,points:d.POINTS_ZERO_REPOS_ACTIVE+d.POINTS_NO_PERSONAL_ACTIVITY,detail:`No personal repos, all ${r.length} events are on repos they don't own`});let c=a<d.AGE_YOUNG_ACCOUNT;if(r.length>=d.MIN_EVENTS_FOR_ANALYSIS){let e=r.filter(e=>e.type===`CreateEvent`&&e.payload?.ref_type===`repository`);if(e.length>=d.CREATE_EVENTS_MIN){let t=e.map(e=>(0,h.default)(e.created_at)).sort((e,t)=>e.valueOf()-t.valueOf()),n=0,r=0;for(let e=0;e<t.length;e++){let i=t[e];for(;i&&i.diff(t[r],`hour`,!0)>24;)r++;let a=e-r+1;n=Math.max(n,a)}n>=d.CREATE_BURST_EXTREME?i.push({label:`Concentrated repository creation`,points:d.POINTS_CREATE_BURST_EXTREME,detail:`${n} repositories created in a short timeframe (within 24 hours)`}):n>=d.CREATE_BURST_HIGH&&i.push({label:`Frequent repository creation`,points:d.POINTS_CREATE_BURST_HIGH,detail:`${n} repositories created in a short timeframe (within 24 hours)`})}let t=new Map;r.forEach(e=>{let n=h.default.utc(e.created_at).format(`YYYY-MM-DD`),r=h.default.utc(e.created_at).hour();t.has(n)||t.set(n,new Set),t.get(n).add(r)});let n=null,a=24;if(t.forEach((e,t)=>{let i=e.size,o=r.filter(e=>h.default.utc(e.created_at).format(`YYYY-MM-DD`)===t).length;if(i>=d.HOURS_ACTIVE_EXTREME&&o>=10&&o/i>=d.EVENTS_PER_HOUR_MIN){let r=Array.from(e).sort((e,t)=>e-t),s=r[0],c=24-r[r.length-1]+s-1;for(let e=0;e<r.length-1;e++){let t=r[e+1]-r[e]-1;c=Math.max(c,t)}c<a&&(a=c,n={day:t,hoursActive:i,restGap:c,eventCount:o})}}),n){let e=n;if(a<3){let t=d.POINTS_24_7_ACTIVITY;a<1&&(t=Math.round(t*1.5)),i.push({label:`24/7 activity pattern`,points:t,detail:`${e.day}: active across ${e.hoursActive} hours with only ${a} hour${a===1?``:`s`} rest`})}}let o=new Map;r.forEach(e=>{e.type&&o.set(e.type,(o.get(e.type)||0)+1)});let s=u(Array.from(o.values())),c=new Set(r.map(e=>e.type).filter(e=>e!=null)),l=c.has(`IssueCommentEvent`)||c.has(`PullRequestReviewEvent`)||c.has(`PullRequestReviewCommentEvent`),f=c.has(`WatchEvent`),p=c.size<=3&&s<.8,m=s>.85&&c.size>=5;(p||m)&&!l&&!f&&i.push({label:`Narrow activity focus`,points:d.POINTS_LOW_DIVERSITY,detail:`${c.size} event types (entropy: ${s.toFixed(2)}) without interpersonal interactions`});let g=r.filter(e=>e.type===`IssueCommentEvent`);if(g.length>=d.ISSUE_COMMENT_MIN_FOR_SPRAY){let e=g.map(e=>({event:e,time:(0,h.default)(e.created_at)})).sort((e,t)=>e.time.valueOf()-t.time.valueOf()),t=0,n=0,r=0,a=0,o=d.ISSUE_COMMENT_SPAM_WINDOW_MINUTES;for(let i=0;i<e.length;i++){let s=e[i]?.time;for(;e[a]&&s&&s.diff(e[a].time,`minute`,!0)>o;)a++;let c=new Set(e.slice(a,i+1).map(e=>e.event.repo?.name).filter(e=>e!==void 0));c.size>t&&(t=c.size,n=a,r=i)}if(t>=d.ISSUE_COMMENT_SPRAY_EXTREME){let a=e[n]?.time,o=e[r]?.time,s=r-n+1,c=o&&a?Math.round(o.diff(a,`minute`,!0)):0;i.push({label:`Issue comment spam`,points:d.POINTS_ISSUE_COMMENT_SPRAY_EXTREME,detail:`${s} comments to ${t} different repos in just ${c} minute${c===1?``:`s`}`})}else if(t>=d.ISSUE_COMMENT_SPRAY_HIGH){let a=e[n]?.time,o=e[r]?.time,s=r-n+1,c=o&&a?Math.round(o.diff(a,`minute`,!0)):0;i.push({label:`High comment frequency across repos`,points:d.POINTS_ISSUE_COMMENT_SPRAY_HIGH,detail:`${s} comments to ${t} different repos in just ${c} minute${c===1?``:`s`}`})}}let _=r.filter(e=>e.type===`PullRequestReviewCommentEvent`);if(_.length>=d.PR_COMMENT_MIN_FOR_SPRAY){let e=_.map(e=>({event:e,time:(0,h.default)(e.created_at)})).sort((e,t)=>e.time.valueOf()-t.time.valueOf()),t=0,n=0,r=0,a=0,o=d.PR_COMMENT_SPAM_WINDOW_MINUTES;for(let i=0;i<e.length;i++){let s=e[i]?.time;for(;e[a]&&s&&s.diff(e[a].time,`minute`,!0)>o;)a++;let c=new Set(e.slice(a,i+1).map(e=>{let t=e.event.repo?.name,n=e.event.payload?.pull_request?.number||e.event.payload?.number||e.event?.issue?.number;return t&&n?`${t}#${n}`:t}).filter(e=>e!==void 0));c.size>t&&(t=c.size,n=a,r=i)}if(t>=d.PR_COMMENT_SPRAY_EXTREME){let a=e[n]?.time,o=e[r]?.time,s=r-n+1,c=o&&a?Math.round(o.diff(a,`minute`,!0)):0;i.push({label:`PR comment spam`,points:d.POINTS_PR_COMMENT_SPRAY_EXTREME,detail:`${s} comments on ${t} different PRs in just ${c} minute${c===1?``:`s`}`})}else if(t>=d.PR_COMMENT_SPRAY_HIGH){let a=e[n]?.time,o=e[r]?.time,s=r-n+1,c=o&&a?Math.round(o.diff(a,`minute`,!0)):0;i.push({label:`High PR comment frequency`,points:d.POINTS_PR_COMMENT_SPRAY_HIGH,detail:`${s} comments on ${t} different PRs in just ${c} minute${c===1?``:`s`}`})}}}let l=a>=d.AGE_ESTABLISHED_ACCOUNT,f=l?d.BRANCH_PR_PATTERN_MIN_PAIRS_ESTABLISHED:d.BRANCH_PR_PATTERN_MIN_PAIRS,p=l?d.BRANCH_PR_PATTERN_RATIO_MIN_ESTABLISHED:d.BRANCH_PR_PATTERN_RATIO_MIN,m=r.filter(e=>e.type===`CreateEvent`&&e.payload?.ref_type===`branch`),g=r.filter(e=>e.type===`PullRequestEvent`&&e.payload?.action===`opened`);if(m.length>=f&&g.length>=f&&m.length/g.length>=d.BRANCH_PR_COUNT_RATIO_MIN){let e=m.map(e=>({event:e,time:(0,h.default)(e.created_at)})).sort((e,t)=>e.time.valueOf()-t.time.valueOf()),t=g.map(e=>({event:e,time:(0,h.default)(e.created_at)})).sort((e,t)=>e.time.valueOf()-t.time.valueOf()),n=0,r=0,a=0;for(let i of e){for(;a<t.length&&t[a].time.valueOf()<i.time.valueOf();)a++;if(a<t.length){let e=t[a].time.diff(i.time,`second`);e>=0&&e<=d.BRANCH_PR_TIME_WINDOW_SECONDS&&(n++,r=Math.max(r,e),a++)}}n>=f&&n/m.length>=p&&i.push({label:`Automated branch/PR workflow`,points:d.POINTS_BRANCH_PR_AUTOMATION,detail:`${n}/${m.length} branch creations followed by PRs within ${r}s`})}let _=r.filter(e=>e.type===`ForkEvent`);if(_.length>=d.FORKS_HIGH){let e=_.map(e=>(0,h.default)(e.created_at)).sort((e,t)=>e.valueOf()-t.valueOf()),t=t=>{let n=0,r=0;for(let i=0;i<e.length;i++){let a=e[i];for(;a&&a.diff(e[r],`hour`,!0)>t;)r++;let o=i-r+1;n=Math.max(n,o)}return n},n=t(24),a=t(48),o=t(72),s=null;if(n>=d.FORKS_SURGE_EXTREME_HIGH?s={label:`Extreme fork automation`,points:d.POINTS_FORK_SURGE_EXTREME_HIGH,detail:`${n} repositories forked in rapid succession (within 24 hours)`}:n>=d.FORKS_SURGE_SEVERE?s={label:`Severe fork surge`,points:d.POINTS_FORK_SURGE_SEVERE,detail:`${n} repositories forked in rapid succession (within 24 hours)`}:n>=d.FORKS_EXTREME?s={label:`Fork spike detected`,points:d.POINTS_FORK_SURGE,detail:`Burst of ${n} fork events in a single 24-hour window`}:n>=d.FORKS_HIGH?s={label:`Multiple forks`,points:d.POINTS_MULTIPLE_FORKS,detail:`${n} repositories forked in a single 24-hour window`}:a>=d.FORKS_SURGE_48H?s={label:`Multi-day fork surge`,points:d.POINTS_FORK_SURGE_48H,detail:`Concentrated burst: ${a} repositories forked over 2 days`}:o>=d.FORKS_SURGE_72H&&(s={label:`Severe multi-day fork surge`,points:d.POINTS_FORK_SURGE_72H,detail:`Rapid burst: ${o} repositories forked over 72 hours`}),s&&i.push(s),e.length>0&&!s){let t=e[0],n=e[e.length-1];if(t&&n){let e=Math.max(1,n.diff(t,`day`)),r=_.length/e;r>=d.FORKS_PER_DAY_HIGH&&e>=3&&i.push({label:`Sustained fork rate`,points:d.POINTS_FORKS_PER_DAY_HIGH,detail:`Average of ${r.toFixed(1)} forks per day over ${e} days (${_.length} total)`})}}let c=new Set;if(_.forEach(e=>{c.add(h.default.utc(e.created_at).format(`YYYY-MM-DD`))}),c.size>=d.CONSECUTIVE_FORK_DAYS&&!s){let e=Array.from(c).map(e=>(0,h.default)(e,`YYYY-MM-DD`)).sort((e,t)=>e.valueOf()-t.valueOf()),t=1,n=1;for(let r=1;r<e.length;r++){let i=e[r-1],a=e[r];a&&i&&a.diff(i,`day`)===1?(n++,t=Math.max(t,n)):n=1}if(t>=d.CONSECUTIVE_FORK_DAYS){let e=c.size;i.push({label:`Extended forking pattern`,points:d.POINTS_CONSECUTIVE_FORK_DAYS,detail:`Forking activity on ${e} days (${t} consecutive), ${_.length} repositories total`})}}let l=new Set(_.map(e=>e.repo?.name).filter(e=>e!==void 0));if(l.size>=d.FORK_REPO_DIVERSITY_HIGH&&!s){let t=``;if(e.length>1){let n=e[0],r=e[e.length-1].diff(n,`day`);t=r>0?` over ${r} days`:` in a short timeframe`}i.push({label:`Fork scatter pattern`,points:d.POINTS_FORK_DIVERSITY,detail:`Targeting ${l.size} different repositories${t}`})}if(_.length>=d.FORK_COMBINED_ACTIVITY_MIN&&r.length>=d.MIN_EVENTS_FOR_ANALYSIS){let e=new Set(_.map(e=>e.repo?.name).filter(e=>e!==void 0)),t=r.filter(e=>e.type===`CreateEvent`&&e.payload?.ref_type===`branch`).filter(t=>e.has(t.repo?.name||``)),n=r.filter(e=>e.type===`PullRequestEvent`&&e.payload?.action===`opened`).filter(t=>e.has(t.repo?.name||``));if(t.length>=d.FORK_COMBINED_BRANCHES&&n.length>=d.FORK_COMBINED_PRS){let e=_.map(e=>(0,h.default)(e.created_at)),r=t.map(e=>(0,h.default)(e.created_at)),a=n.map(e=>(0,h.default)(e.created_at)),o=h.default.max(e),s=h.default.min(r),c=h.default.min(a);if(o&&s&&c&&o.isBefore(s)&&s.isBefore(c)&&n.length<=t.length*2){let e=_.length+t.length+n.length;i.push({label:`Suspicious chained automations`,points:d.POINTS_FORK_COMBINED_ACTIVITY,detail:`${e} chained repository operations: ${_.length} forks followed by ${t.length} branches, then ${n.length} pull requests (based on available event history)`})}}}}if(c&&r.length>=d.MIN_EVENTS_FOR_ANALYSIS){let e=n.toLowerCase(),a=r.filter(e=>e.type===`PushEvent`);if(a.length>=d.MIN_EVENTS_FOR_ANALYSIS){let e=a.map(e=>(0,h.default)(e.created_at)).sort((e,t)=>e.valueOf()-t.valueOf()),t=0,n=0;for(let r=0;r<e.length;r++){let i=e[r];for(;i&&i.diff(e[n],`hour`,!0)>1;)n++;let a=r-n+1;t=Math.max(t,a)}t>=d.HOURLY_ACTIVITY_EXTREME?i.push({label:`Extreme commit burst`,points:d.POINTS_EXTREME_ACTIVITY_DENSITY,detail:`${t} commits within 1 hour`}):t>=d.HOURLY_ACTIVITY_HIGH&&i.push({label:`High commit burst`,points:d.POINTS_HIGH_ACTIVITY_DENSITY,detail:`${t} commits within 1 hour`});let r=0;for(let t=1;t<e.length;t++)e[t]!==void 0&&e[t-1]!==void 0&&e[t].diff(e[t-1],`second`)<=d.TIGHT_COMMIT_SECONDS&&r++;r>=d.TIGHT_COMMIT_THRESHOLD&&i.push({label:`High commit frequency`,points:d.POINTS_TIGHT_BURST,detail:`${r+1} commits within very short intervals`})}let l=r.filter(e=>e.type===`PullRequestEvent`&&e.payload?.action===`opened`);if(l.length>=d.MIN_EVENTS_FOR_ANALYSIS){let e=l.map(e=>(0,h.default)(e.created_at)),t=h.default.min(e),n=h.default.max(e);if(n){let e=Math.max(1,n.diff(t,`day`)),r=l.length/e;r>=d.ACTIVITY_DENSITY_EXTREME/2?i.push({label:`Very high PR volume`,points:d.POINTS_EXTREME_ACTIVITY_DENSITY+10,detail:`${l.length} PRs in ${e} day${e===1?``:`s`}`}):r>=d.ACTIVITY_DENSITY_HIGH/2&&i.push({label:`High PR volume`,points:d.POINTS_HIGH_ACTIVITY_DENSITY+5,detail:`${l.length} PRs in ${e} day${e===1?``:`s`}`})}}let f=new Set([`PushEvent`,`PullRequestEvent`]),p=r.filter(e=>e.type&&f.has(e.type)||e.type===`PullRequestReviewEvent`||e.type===`PullRequestReviewCommentEvent`),m=new Map;p.forEach(e=>{if(!e.created_at)return;let t=new Date(e.created_at),n=t.toISOString().slice(0,10);m.has(n)||m.set(n,[]),m.get(n).push(t)});let g=[];if(m.forEach((e,t)=>{let n=new Map;e.forEach(e=>{let t=e.getUTCHours();n.set(t,(n.get(t)||0)+1)});let r=n.size,i=u(Array.from(n.values()));r>=d.HOURS_PER_DAY_INHUMAN&&i>.8&&g.push(t)}),g.length>=d.CONSECUTIVE_INHUMAN_DAYS_EXTREME){g.sort();let e=1,t=1;for(let n=1;n<g.length;n++){let r=(0,h.default)(g[n-1]);(0,h.default)(g[n]).diff(r,`day`)===1?(e++,t=Math.max(t,e)):e=1}t>=d.CONSECUTIVE_INHUMAN_DAYS_EXTREME?i.push({label:`Extended daily coding`,points:d.POINTS_NONSTOP_ACTIVITY,detail:`${t} days in a row with ${d.HOURS_PER_DAY_INHUMAN}+ hours of coding`}):g.length>=d.FREQUENT_MARATHON_DAYS&&i.push({label:`Frequent long coding days`,points:d.POINTS_FREQUENT_MARATHON,detail:`${g.length} days with ${d.HOURS_PER_DAY_INHUMAN}+ hours of coding and uniform hourly distribution`})}if(c){let t=new Set(r.map(e=>e.repo?.name).filter(t=>t?t.split(`/`)[0]?.toLowerCase()!==e:!1));t.size>=d.REPO_SPREAD_EXTREME?i.push({label:`Highly distributed activity`,points:d.POINTS_EXTREME_REPO_SPREAD_YOUNG,detail:`Activity spread across ${t.size} external repositories`}):t.size>=d.REPO_SPREAD_HIGH&&i.push({label:`Distributed activity`,points:d.POINTS_WIDE_REPO_SPREAD_YOUNG,detail:`Activity spread across ${t.size} external repositories`})}let _=l.filter(t=>{let n=t.repo?.name?.split(`/`)[0]?.toLowerCase();return n&&n!==e}),v=(0,h.default)(),y=v.subtract(1,`week`),b=v.subtract(1,`day`),x=_.filter(e=>(0,h.default)(e.created_at).isAfter(y)),S=_.filter(e=>(0,h.default)(e.created_at).isAfter(b));if(S.length>=d.PRS_TODAY_EXTREME?i.push({label:`High PR volume in the past 24 hours`,points:d.POINTS_PR_BURST,detail:`${S.length} PRs to other repos in the last 24 hours`}):x.length>=d.PRS_WEEK_HIGH&&i.push({label:`High PR volume during last week`,points:d.POINTS_HIGH_PR_FREQUENCY,detail:`${x.length} PRs to other repos this week`}),_.length>=d.EXTERNAL_PRS_MIN&&t<d.PERSONAL_REPOS_LOW){let e=`${_.length} PRs to other repos, but only ${t} of their own`;t===0&&(e=`${_.length} PRs to other repos, none of their own`),i.push({label:`Primarily external contributions`,points:d.POINTS_PR_ONLY_CONTRIBUTOR,detail:e})}let C=o.length/r.length;!s&&C>=d.FOREIGN_RATIO_HIGH&&t<d.PERSONAL_REPOS_LOW&&i.push({label:`Mostly external activity`,points:d.POINTS_EXTERNAL_FOCUS,detail:`${Math.round(C*100)}% of activity on other people's repos`})}if(r.length>=d.MIN_EVENTS_FOR_ANALYSIS){let e=r.filter(e=>e.type===`PullRequestEvent`&&e.payload?.action===`opened`),t=(0,h.default)(),n=t.subtract(1,`day`),a=t.subtract(1,`week`),o=e.filter(e=>(0,h.default)(e.created_at).isAfter(n)),s=e.filter(e=>(0,h.default)(e.created_at).isAfter(a));if(o.length>=d.PRS_DAY_EXTREME&&i.push({label:`Extreme PR spam (daily)`,points:d.POINTS_PRS_DAY_EXTREME,detail:`${o.length} PRs in the last 24 hours`}),s.length>=d.PRS_WEEK_EXTREME?i.push({label:`Extreme PR spam (weekly)`,points:d.POINTS_PRS_WEEK_EXTREME,detail:`${s.length} PRs in the last 7 days`}):s.length>=d.PRS_WEEK_VERY_HIGH&&i.push({label:`Very high PR spam frequency`,points:d.POINTS_PRS_WEEK_VERY_HIGH,detail:`${s.length} PRs in the last 7 days`}),e.length>=d.PRS_SPAM_VOLUME&&!i.some(e=>e.label===`Extreme PR spam (daily)`||e.label===`Extreme PR spam (weekly)`||e.label===`Very high PR spam frequency`)){let t=new Set(e.map(e=>e.repo?.name).filter(e=>e!==void 0));if(t.size>=d.REPOS_SPAM_SPREAD){let n=e.map(e=>(0,h.default)(e.created_at)).sort((e,t)=>e.valueOf()-t.valueOf()),r=n[0],a=n[n.length-1],o=a?a.diff(r,`days`,!0):0,s=o/7,c=s>0?e.length/s:1/0,l=(0,h.default)().subtract(30,`days`),u=e.filter(e=>(0,h.default)(e.created_at).isAfter(l)).length,f=c>=d.PRS_SPAM_DENSITY_PER_WEEK,p=u>=d.PRS_SPAM_ROLLING_30DAYS;(f||p)&&i.push({label:`Distributed PR spam pattern`,points:d.POINTS_PR_SPAM_DISTRIBUTED,detail:`${e.length} PRs spread across ${t.size} different repositories${o>0?` (${c.toFixed(1)} PRs/week)`:``}`})}}}let v=i.reduce((e,t)=>e+=t.points,0),y=Math.max(0,100-v),b=`automation`;return y>=d.THRESHOLD_HUMAN?b=`organic`:y>=d.THRESHOLD_SUSPICIOUS&&(b=`mixed`),{score:y,classification:b,flags:i,profile:{age:a,repos:t}}}function y(e){return e?e===`organic`?{label:`Organic activity`,description:`No automation signals detected in the analyzed events.`}:e===`mixed`?{label:`Mixed activity`,description:`Activity patterns show a mix of organic and automated signals.`}:{label:`Automation signals`,description:`Activity patterns show signs of automation.`}:{label:`Analysis unavailable`,description:`Classification is not available for this account.`}}export{y as getClassificationDetails,v as identify,d as identityConfig};
|
|
1
|
+
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),s=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},c=(n,r,a)=>(a=n==null?{}:e(i(n)),s(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));function l(e){if(e.length===0)return 0;let t=e.reduce((e,t)=>e+t,0);if(t===0)return 0;let n=0;for(let r of e)if(r>0){let e=r/t;n-=e*Math.log2(e)}return n}function u(e){return e.length<=1?0:l(e)/Math.log2(e.length)}const d={THRESHOLD_HUMAN:70,THRESHOLD_SUSPICIOUS:50,AGE_NEW_ACCOUNT:30,AGE_YOUNG_ACCOUNT:90,POINTS_NEW_ACCOUNT:20,POINTS_YOUNG_ACCOUNT:10,POINTS_NO_IDENTITY:15,FOLLOW_RATIO_FOLLOWING_MIN:50,FOLLOW_RATIO_FOLLOWERS_MAX:5,POINTS_FOLLOW_RATIO:15,POINTS_ZERO_FOLLOWERS:10,MIN_EVENTS_FOR_ANALYSIS:10,FORKS_EXTREME:8,FORKS_HIGH:5,FORKS_SURGE_SEVERE:20,FORKS_SURGE_EXTREME_HIGH:35,FORK_SURGE_WINDOW_HOURS:24,POINTS_FORK_SURGE:51,POINTS_FORK_SURGE_SEVERE:70,POINTS_FORK_SURGE_EXTREME_HIGH:85,POINTS_MULTIPLE_FORKS:26,FORKS_SURGE_48H:18,FORKS_SURGE_72H:25,POINTS_FORK_SURGE_48H:65,POINTS_FORK_SURGE_72H:75,FORKS_PER_DAY_HIGH:8,POINTS_FORKS_PER_DAY_HIGH:55,CONSECUTIVE_FORK_DAYS:6,POINTS_CONSECUTIVE_FORK_DAYS:40,FORK_COMBINED_ACTIVITY_MIN:12,FORK_COMBINED_BRANCHES:6,FORK_COMBINED_PRS:8,POINTS_FORK_COMBINED_ACTIVITY:60,FORK_REPO_DIVERSITY_HIGH:15,POINTS_FORK_DIVERSITY:45,HOURS_PER_DAY_INHUMAN:16,CONSECUTIVE_INHUMAN_DAYS_EXTREME:3,FREQUENT_MARATHON_DAYS:5,POINTS_NONSTOP_ACTIVITY:40,POINTS_FREQUENT_MARATHON:25,REPO_SPREAD_EXTREME:30,REPO_SPREAD_HIGH:20,POINTS_EXTREME_REPO_SPREAD_YOUNG:30,POINTS_WIDE_REPO_SPREAD_YOUNG:15,PRS_TODAY_EXTREME:15,PRS_WEEK_HIGH:20,POINTS_PR_BURST:20,POINTS_HIGH_PR_FREQUENCY:15,PRS_DAY_EXTREME:30,POINTS_PRS_DAY_EXTREME:45,PRS_WEEK_EXTREME:100,POINTS_PRS_WEEK_EXTREME:50,PRS_WEEK_VERY_HIGH:50,POINTS_PRS_WEEK_VERY_HIGH:40,PRS_SPAM_VOLUME:50,REPOS_SPAM_SPREAD:15,POINTS_PR_SPAM_COMBINED:45,PRS_SPAM_DENSITY_PER_WEEK:15,PRS_SPAM_ROLLING_30DAYS:60,POINTS_PR_SPAM_DISTRIBUTED:45,EXTERNAL_PRS_MIN:15,PERSONAL_REPOS_LOW:5,POINTS_PR_ONLY_CONTRIBUTOR:20,FOREIGN_RATIO_FULL:1,FOREIGN_RATIO_HIGH:.95,PERSONAL_REPOS_NONE:3,POINTS_NO_PERSONAL_ACTIVITY:30,POINTS_EXTERNAL_FOCUS:20,ZERO_REPOS_MIN_EVENTS:20,POINTS_ZERO_REPOS_ACTIVE:20,ACTIVITY_DENSITY_HIGH:8,ACTIVITY_DENSITY_EXTREME:15,POINTS_HIGH_ACTIVITY_DENSITY:15,POINTS_EXTREME_ACTIVITY_DENSITY:25,HOURLY_ACTIVITY_HIGH:50,HOURLY_ACTIVITY_EXTREME:100,TIGHT_COMMIT_SECONDS:600,TIGHT_COMMIT_THRESHOLD:3,POINTS_TIGHT_BURST:25,CREATE_EVENTS_MIN:5,CREATE_BURST_EXTREME:16,CREATE_BURST_HIGH:8,POINTS_CREATE_BURST_EXTREME:35,POINTS_CREATE_BURST_HIGH:25,HOURS_ACTIVE_EXTREME:21,HOURS_ACTIVE_EXTREME_ESTABLISHED:23,EVENTS_PER_HOUR_MIN:2,POINTS_24_7_ACTIVITY:25,AGE_ESTABLISHED_ACCOUNT:1e3,EVENT_TYPE_DIVERSITY_MIN:2,POINTS_LOW_DIVERSITY:20,ISSUE_COMMENT_SPAM_WINDOW_MINUTES:2,ISSUE_COMMENT_SPRAY_EXTREME:15,ISSUE_COMMENT_SPRAY_HIGH:10,ISSUE_COMMENT_MIN_FOR_SPRAY:10,POINTS_ISSUE_COMMENT_SPRAY_EXTREME:40,POINTS_ISSUE_COMMENT_SPRAY_HIGH:30,PR_COMMENT_SPAM_WINDOW_MINUTES:2,PR_COMMENT_SPRAY_EXTREME:12,PR_COMMENT_SPRAY_HIGH:8,PR_COMMENT_MIN_FOR_SPRAY:8,POINTS_PR_COMMENT_SPRAY_EXTREME:38,POINTS_PR_COMMENT_SPRAY_HIGH:28,BRANCH_PR_TIME_WINDOW_SECONDS:90,BRANCH_PR_PATTERN_MIN_PAIRS:8,BRANCH_PR_PATTERN_MIN_PAIRS_ESTABLISHED:15,BRANCH_PR_PATTERN_RATIO_MIN:.65,BRANCH_PR_PATTERN_RATIO_MIN_ESTABLISHED:.8,BRANCH_PR_COUNT_RATIO_MIN:.65,POINTS_BRANCH_PR_AUTOMATION:35};var f=o(((e,t)=>{(function(n,r){typeof e==`object`&&t!==void 0?t.exports=r():typeof define==`function`&&define.amd?define(r):(n=typeof globalThis<`u`?globalThis:n||self).dayjs=r()})(e,(function(){var e=1e3,t=6e4,n=36e5,r=`millisecond`,i=`second`,a=`minute`,o=`hour`,s=`day`,c=`week`,l=`month`,u=`quarter`,d=`year`,f=`date`,p=`Invalid Date`,m=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,h=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,g={name:`en`,weekdays:`Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday`.split(`_`),months:`January_February_March_April_May_June_July_August_September_October_November_December`.split(`_`),ordinal:function(e){var t=[`th`,`st`,`nd`,`rd`],n=e%100;return`[`+e+(t[(n-20)%10]||t[n]||t[0])+`]`}},_=function(e,t,n){var r=String(e);return!r||r.length>=t?e:``+Array(t+1-r.length).join(n)+e},v={s:_,z:function(e){var t=-e.utcOffset(),n=Math.abs(t),r=Math.floor(n/60),i=n%60;return(t<=0?`+`:`-`)+_(r,2,`0`)+`:`+_(i,2,`0`)},m:function e(t,n){if(t.date()<n.date())return-e(n,t);var r=12*(n.year()-t.year())+(n.month()-t.month()),i=t.clone().add(r,l),a=n-i<0,o=t.clone().add(r+(a?-1:1),l);return+(-(r+(n-i)/(a?i-o:o-i))||0)},a:function(e){return e<0?Math.ceil(e)||0:Math.floor(e)},p:function(e){return{M:l,y:d,w:c,d:s,D:f,h:o,m:a,s:i,ms:r,Q:u}[e]||String(e||``).toLowerCase().replace(/s$/,``)},u:function(e){return e===void 0}},y=`en`,b={};b[y]=g;var x=`$isDayjsObject`,S=function(e){return e instanceof E||!(!e||!e[x])},C=function e(t,n,r){var i;if(!t)return y;if(typeof t==`string`){var a=t.toLowerCase();b[a]&&(i=a),n&&(b[a]=n,i=a);var o=t.split(`-`);if(!i&&o.length>1)return e(o[0])}else{var s=t.name;b[s]=t,i=s}return!r&&i&&(y=i),i||!r&&y},w=function(e,t){if(S(e))return e.clone();var n=typeof t==`object`?t:{};return n.date=e,n.args=arguments,new E(n)},T=v;T.l=C,T.i=S,T.w=function(e,t){return w(e,{locale:t.$L,utc:t.$u,x:t.$x,$offset:t.$offset})};var E=function(){function g(e){this.$L=C(e.locale,null,!0),this.parse(e),this.$x=this.$x||e.x||{},this[x]=!0}var _=g.prototype;return _.parse=function(e){this.$d=function(e){var t=e.date,n=e.utc;if(t===null)return new Date(NaN);if(T.u(t))return new Date;if(t instanceof Date)return new Date(t);if(typeof t==`string`&&!/Z$/i.test(t)){var r=t.match(m);if(r){var i=r[2]-1||0,a=(r[7]||`0`).substring(0,3);return n?new Date(Date.UTC(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,a)):new Date(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,a)}}return new Date(t)}(e),this.init()},_.init=function(){var e=this.$d;this.$y=e.getFullYear(),this.$M=e.getMonth(),this.$D=e.getDate(),this.$W=e.getDay(),this.$H=e.getHours(),this.$m=e.getMinutes(),this.$s=e.getSeconds(),this.$ms=e.getMilliseconds()},_.$utils=function(){return T},_.isValid=function(){return this.$d.toString()!==p},_.isSame=function(e,t){var n=w(e);return this.startOf(t)<=n&&n<=this.endOf(t)},_.isAfter=function(e,t){return w(e)<this.startOf(t)},_.isBefore=function(e,t){return this.endOf(t)<w(e)},_.$g=function(e,t,n){return T.u(e)?this[t]:this.set(n,e)},_.unix=function(){return Math.floor(this.valueOf()/1e3)},_.valueOf=function(){return this.$d.getTime()},_.startOf=function(e,t){var n=this,r=!!T.u(t)||t,u=T.p(e),p=function(e,t){var i=T.w(n.$u?Date.UTC(n.$y,t,e):new Date(n.$y,t,e),n);return r?i:i.endOf(s)},m=function(e,t){return T.w(n.toDate()[e].apply(n.toDate(`s`),(r?[0,0,0,0]:[23,59,59,999]).slice(t)),n)},h=this.$W,g=this.$M,_=this.$D,v=`set`+(this.$u?`UTC`:``);switch(u){case d:return r?p(1,0):p(31,11);case l:return r?p(1,g):p(0,g+1);case c:var y=this.$locale().weekStart||0,b=(h<y?h+7:h)-y;return p(r?_-b:_+(6-b),g);case s:case f:return m(v+`Hours`,0);case o:return m(v+`Minutes`,1);case a:return m(v+`Seconds`,2);case i:return m(v+`Milliseconds`,3);default:return this.clone()}},_.endOf=function(e){return this.startOf(e,!1)},_.$set=function(e,t){var n,c=T.p(e),u=`set`+(this.$u?`UTC`:``),p=(n={},n[s]=u+`Date`,n[f]=u+`Date`,n[l]=u+`Month`,n[d]=u+`FullYear`,n[o]=u+`Hours`,n[a]=u+`Minutes`,n[i]=u+`Seconds`,n[r]=u+`Milliseconds`,n)[c],m=c===s?this.$D+(t-this.$W):t;if(c===l||c===d){var h=this.clone().set(f,1);h.$d[p](m),h.init(),this.$d=h.set(f,Math.min(this.$D,h.daysInMonth())).$d}else p&&this.$d[p](m);return this.init(),this},_.set=function(e,t){return this.clone().$set(e,t)},_.get=function(e){return this[T.p(e)]()},_.add=function(r,u){var f,p=this;r=Number(r);var m=T.p(u),h=function(e){var t=w(p);return T.w(t.date(t.date()+Math.round(e*r)),p)};if(m===l)return this.set(l,this.$M+r);if(m===d)return this.set(d,this.$y+r);if(m===s)return h(1);if(m===c)return h(7);var g=(f={},f[a]=t,f[o]=n,f[i]=e,f)[m]||1,_=this.$d.getTime()+r*g;return T.w(_,this)},_.subtract=function(e,t){return this.add(-1*e,t)},_.format=function(e){var t=this,n=this.$locale();if(!this.isValid())return n.invalidDate||p;var r=e||`YYYY-MM-DDTHH:mm:ssZ`,i=T.z(this),a=this.$H,o=this.$m,s=this.$M,c=n.weekdays,l=n.months,u=n.meridiem,d=function(e,n,i,a){return e&&(e[n]||e(t,r))||i[n].slice(0,a)},f=function(e){return T.s(a%12||12,e,`0`)},m=u||function(e,t,n){var r=e<12?`AM`:`PM`;return n?r.toLowerCase():r};return r.replace(h,(function(e,r){return r||function(e){switch(e){case`YY`:return String(t.$y).slice(-2);case`YYYY`:return T.s(t.$y,4,`0`);case`M`:return s+1;case`MM`:return T.s(s+1,2,`0`);case`MMM`:return d(n.monthsShort,s,l,3);case`MMMM`:return d(l,s);case`D`:return t.$D;case`DD`:return T.s(t.$D,2,`0`);case`d`:return String(t.$W);case`dd`:return d(n.weekdaysMin,t.$W,c,2);case`ddd`:return d(n.weekdaysShort,t.$W,c,3);case`dddd`:return c[t.$W];case`H`:return String(a);case`HH`:return T.s(a,2,`0`);case`h`:return f(1);case`hh`:return f(2);case`a`:return m(a,o,!0);case`A`:return m(a,o,!1);case`m`:return String(o);case`mm`:return T.s(o,2,`0`);case`s`:return String(t.$s);case`ss`:return T.s(t.$s,2,`0`);case`SSS`:return T.s(t.$ms,3,`0`);case`Z`:return i}return null}(e)||i.replace(`:`,``)}))},_.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},_.diff=function(r,f,p){var m,h=this,g=T.p(f),_=w(r),v=(_.utcOffset()-this.utcOffset())*t,y=this-_,b=function(){return T.m(h,_)};switch(g){case d:m=b()/12;break;case l:m=b();break;case u:m=b()/3;break;case c:m=(y-v)/6048e5;break;case s:m=(y-v)/864e5;break;case o:m=y/n;break;case a:m=y/t;break;case i:m=y/e;break;default:m=y}return p?m:T.a(m)},_.daysInMonth=function(){return this.endOf(l).$D},_.$locale=function(){return b[this.$L]},_.locale=function(e,t){if(!e)return this.$L;var n=this.clone(),r=C(e,t,!0);return r&&(n.$L=r),n},_.clone=function(){return T.w(this.$d,this)},_.toDate=function(){return new Date(this.valueOf())},_.toJSON=function(){return this.isValid()?this.toISOString():null},_.toISOString=function(){return this.$d.toISOString()},_.toString=function(){return this.$d.toUTCString()},g}(),D=E.prototype;return w.prototype=D,[[`$ms`,r],[`$s`,i],[`$m`,a],[`$H`,o],[`$W`,s],[`$M`,l],[`$y`,d],[`$D`,f]].forEach((function(e){D[e[1]]=function(t){return this.$g(t,e[0],e[1])}})),w.extend=function(e,t){return e.$i||=(e(t,E,w),!0),w},w.locale=C,w.isDayjs=S,w.unix=function(e){return w(1e3*e)},w.en=b[y],w.Ls=b,w.p={},w}))})),p=o(((e,t)=>{(function(n,r){typeof e==`object`&&t!==void 0?t.exports=r():typeof define==`function`&&define.amd?define(r):(n=typeof globalThis<`u`?globalThis:n||self).dayjs_plugin_minMax=r()})(e,(function(){return function(e,t,n){var r=function(e,t){if(!t||!t.length||t.length===1&&!t[0]||t.length===1&&Array.isArray(t[0])&&!t[0].length)return null;var n;t.length===1&&t[0].length>0&&(t=t[0]),n=(t=t.filter((function(e){return e})))[0];for(var r=1;r<t.length;r+=1)t[r].isValid()&&!t[r][e](n)||(n=t[r]);return n};n.max=function(){return r(`isAfter`,[].slice.call(arguments,0))},n.min=function(){return r(`isBefore`,[].slice.call(arguments,0))}}}))})),m=o(((e,t)=>{(function(n,r){typeof e==`object`&&t!==void 0?t.exports=r():typeof define==`function`&&define.amd?define(r):(n=typeof globalThis<`u`?globalThis:n||self).dayjs_plugin_utc=r()})(e,(function(){var e=`minute`,t=/[+-]\d\d(?::?\d\d)?/g,n=/([+-]|\d\d)/g;return function(r,i,a){var o=i.prototype;a.utc=function(e){return new i({date:e,utc:!0,args:arguments})},o.utc=function(t){var n=a(this.toDate(),{locale:this.$L,utc:!0});return t?n.add(this.utcOffset(),e):n},o.local=function(){return a(this.toDate(),{locale:this.$L,utc:!1})};var s=o.parse;o.parse=function(e){e.utc&&(this.$u=!0),this.$utils().u(e.$offset)||(this.$offset=e.$offset),s.call(this,e)};var c=o.init;o.init=function(){if(this.$u){var e=this.$d;this.$y=e.getUTCFullYear(),this.$M=e.getUTCMonth(),this.$D=e.getUTCDate(),this.$W=e.getUTCDay(),this.$H=e.getUTCHours(),this.$m=e.getUTCMinutes(),this.$s=e.getUTCSeconds(),this.$ms=e.getUTCMilliseconds()}else c.call(this)};var l=o.utcOffset;o.utcOffset=function(r,i){var a=this.$utils().u;if(a(r))return this.$u?0:a(this.$offset)?l.call(this):this.$offset;if(typeof r==`string`&&(r=function(e){e===void 0&&(e=``);var r=e.match(t);if(!r)return null;var i=(``+r[0]).match(n)||[`-`,0,0],a=i[0],o=60*i[1]+ +i[2];return o===0?0:a===`+`?o:-o}(r),r===null))return this;var o=Math.abs(r)<=16?60*r:r;if(o===0)return this.utc(i);var s=this.clone();if(i)return s.$offset=o,s.$u=!1,s;var c=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();return(s=this.local().add(o+c,e)).$offset=o,s.$x.$localOffset=c,s};var u=o.format;o.format=function(e){var t=e||(this.$u?`YYYY-MM-DDTHH:mm:ss[Z]`:``);return u.call(this,t)},o.valueOf=function(){var e=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*e},o.isUTC=function(){return!!this.$u},o.toISOString=function(){return this.toDate().toISOString()},o.toString=function(){return this.toDate().toUTCString()};var d=o.toDate;o.toDate=function(e){return e===`s`&&this.$offset?a(this.format(`YYYY-MM-DD HH:mm:ss:SSS`)).toDate():d.call(this)};var f=o.diff;o.diff=function(e,t,n){if(e&&this.$u===e.$u)return f.call(this,e,t,n);var r=this.local(),i=a(e).local();return f.call(r,i,t,n)}}}))})),h=c(f(),1),g=c(p(),1),_=c(m(),1);h.default.extend(g.default),h.default.extend(_.default);function v({createdAt:e,reposCount:t,accountName:n,events:r,excludeRepos:i=[]}){let a=[],o=i.map(e=>e.toLowerCase()),s=r.filter(e=>{let t=e.repo?.name?.toLowerCase();return t&&!o.includes(t)}),c=(0,h.default)().diff(e,`days`);c<d.AGE_NEW_ACCOUNT?a.push({label:`Recently created`,points:d.POINTS_NEW_ACCOUNT,detail:`Account is ${c} days old`}):c<d.AGE_YOUNG_ACCOUNT&&a.push({label:`Young account`,points:d.POINTS_YOUNG_ACCOUNT,detail:`Account is ${c} days old`});let l=s.filter(e=>{let t=e.repo?.name?.split(`/`)[0]?.toLowerCase();return t&&t!==n.toLowerCase()}),f=t===0&&l.length===s.length;f&&s.length>=d.ZERO_REPOS_MIN_EVENTS&&a.push({label:`Only active on other people's repos`,points:d.POINTS_ZERO_REPOS_ACTIVE+d.POINTS_NO_PERSONAL_ACTIVITY,detail:`No personal repos, all ${s.length} events are on repos they don't own`});let p=c<d.AGE_YOUNG_ACCOUNT;if(s.length>=d.MIN_EVENTS_FOR_ANALYSIS){let e=s.filter(e=>e.type===`CreateEvent`&&e.payload?.ref_type===`repository`);if(e.length>=d.CREATE_EVENTS_MIN){let t=e.map(e=>(0,h.default)(e.created_at)).sort((e,t)=>e.valueOf()-t.valueOf()),n=0,r=0;for(let e=0;e<t.length;e++){let i=t[e];for(;i&&i.diff(t[r],`hour`,!0)>24;)r++;let a=e-r+1;n=Math.max(n,a)}n>=d.CREATE_BURST_EXTREME?a.push({label:`Concentrated repository creation`,points:d.POINTS_CREATE_BURST_EXTREME,detail:`${n} repositories created in a short timeframe (within 24 hours)`}):n>=d.CREATE_BURST_HIGH&&a.push({label:`Frequent repository creation`,points:d.POINTS_CREATE_BURST_HIGH,detail:`${n} repositories created in a short timeframe (within 24 hours)`})}let t=new Map;s.forEach(e=>{let n=h.default.utc(e.created_at).format(`YYYY-MM-DD`),r=h.default.utc(e.created_at).hour();t.has(n)||t.set(n,new Set),t.get(n).add(r)});let n=null,r=24;if(t.forEach((e,t)=>{let i=e.size,a=s.filter(e=>h.default.utc(e.created_at).format(`YYYY-MM-DD`)===t).length;if(i>=d.HOURS_ACTIVE_EXTREME&&a>=10&&a/i>=d.EVENTS_PER_HOUR_MIN){let o=Array.from(e).sort((e,t)=>e-t),s=o[0],c=24-o[o.length-1]+s-1;for(let e=0;e<o.length-1;e++){let t=o[e+1]-o[e]-1;c=Math.max(c,t)}c<r&&(r=c,n={day:t,hoursActive:i,restGap:c,eventCount:a})}}),n){let e=n;if(r<3){let t=d.POINTS_24_7_ACTIVITY;r<1&&(t=Math.round(t*1.5)),a.push({label:`24/7 activity pattern`,points:t,detail:`${e.day}: active across ${e.hoursActive} hours with only ${r} hour${r===1?``:`s`} rest`})}}let i=new Map;s.forEach(e=>{e.type&&i.set(e.type,(i.get(e.type)||0)+1)});let o=u(Array.from(i.values())),c=new Set(s.map(e=>e.type).filter(e=>e!=null)),l=c.has(`IssueCommentEvent`)||c.has(`PullRequestReviewEvent`)||c.has(`PullRequestReviewCommentEvent`),f=c.has(`WatchEvent`),p=c.size<=3&&o<.8,m=o>.85&&c.size>=5;(p||m)&&!l&&!f&&a.push({label:`Narrow activity focus`,points:d.POINTS_LOW_DIVERSITY,detail:`${c.size} event types (entropy: ${o.toFixed(2)}) without interpersonal interactions`});let g=s.filter(e=>e.type===`IssueCommentEvent`);if(g.length>=d.ISSUE_COMMENT_MIN_FOR_SPRAY){let e=g.map(e=>({event:e,time:(0,h.default)(e.created_at)})).sort((e,t)=>e.time.valueOf()-t.time.valueOf()),t=0,n=0,r=0,i=0,o=d.ISSUE_COMMENT_SPAM_WINDOW_MINUTES;for(let a=0;a<e.length;a++){let s=e[a]?.time;for(;e[i]&&s&&s.diff(e[i].time,`minute`,!0)>o;)i++;let c=new Set(e.slice(i,a+1).map(e=>e.event.repo?.name).filter(e=>e!==void 0));c.size>t&&(t=c.size,n=i,r=a)}if(t>=d.ISSUE_COMMENT_SPRAY_EXTREME){let i=e[n]?.time,o=e[r]?.time,s=r-n+1,c=o&&i?Math.round(o.diff(i,`minute`,!0)):0;a.push({label:`Issue comment spam`,points:d.POINTS_ISSUE_COMMENT_SPRAY_EXTREME,detail:`${s} comments to ${t} different repos in just ${c} minute${c===1?``:`s`}`})}else if(t>=d.ISSUE_COMMENT_SPRAY_HIGH){let i=e[n]?.time,o=e[r]?.time,s=r-n+1,c=o&&i?Math.round(o.diff(i,`minute`,!0)):0;a.push({label:`High comment frequency across repos`,points:d.POINTS_ISSUE_COMMENT_SPRAY_HIGH,detail:`${s} comments to ${t} different repos in just ${c} minute${c===1?``:`s`}`})}}let _=s.filter(e=>e.type===`PullRequestReviewCommentEvent`);if(_.length>=d.PR_COMMENT_MIN_FOR_SPRAY){let e=_.map(e=>({event:e,time:(0,h.default)(e.created_at)})).sort((e,t)=>e.time.valueOf()-t.time.valueOf()),t=0,n=0,r=0,i=0,o=d.PR_COMMENT_SPAM_WINDOW_MINUTES;for(let a=0;a<e.length;a++){let s=e[a]?.time;for(;e[i]&&s&&s.diff(e[i].time,`minute`,!0)>o;)i++;let c=new Set(e.slice(i,a+1).map(e=>{let t=e.event.repo?.name,n=e.event.payload?.pull_request?.number||e.event.payload?.number||e.event?.issue?.number;return t&&n?`${t}#${n}`:t}).filter(e=>e!==void 0));c.size>t&&(t=c.size,n=i,r=a)}if(t>=d.PR_COMMENT_SPRAY_EXTREME){let i=e[n]?.time,o=e[r]?.time,s=r-n+1,c=o&&i?Math.round(o.diff(i,`minute`,!0)):0;a.push({label:`PR comment spam`,points:d.POINTS_PR_COMMENT_SPRAY_EXTREME,detail:`${s} comments on ${t} different PRs in just ${c} minute${c===1?``:`s`}`})}else if(t>=d.PR_COMMENT_SPRAY_HIGH){let i=e[n]?.time,o=e[r]?.time,s=r-n+1,c=o&&i?Math.round(o.diff(i,`minute`,!0)):0;a.push({label:`High PR comment frequency`,points:d.POINTS_PR_COMMENT_SPRAY_HIGH,detail:`${s} comments on ${t} different PRs in just ${c} minute${c===1?``:`s`}`})}}}let m=c>=d.AGE_ESTABLISHED_ACCOUNT,g=m?d.BRANCH_PR_PATTERN_MIN_PAIRS_ESTABLISHED:d.BRANCH_PR_PATTERN_MIN_PAIRS,_=m?d.BRANCH_PR_PATTERN_RATIO_MIN_ESTABLISHED:d.BRANCH_PR_PATTERN_RATIO_MIN,v=s.filter(e=>e.type===`CreateEvent`&&e.payload?.ref_type===`branch`),y=s.filter(e=>e.type===`PullRequestEvent`&&e.payload?.action===`opened`);if(v.length>=g&&y.length>=g&&v.length/y.length>=d.BRANCH_PR_COUNT_RATIO_MIN){let e=v.map(e=>({event:e,time:(0,h.default)(e.created_at)})).sort((e,t)=>e.time.valueOf()-t.time.valueOf()),t=y.map(e=>({event:e,time:(0,h.default)(e.created_at)})).sort((e,t)=>e.time.valueOf()-t.time.valueOf()),n=0,r=0,i=0;for(let a of e){for(;i<t.length&&t[i].time.valueOf()<a.time.valueOf();)i++;if(i<t.length){let e=t[i].time.diff(a.time,`second`);e>=0&&e<=d.BRANCH_PR_TIME_WINDOW_SECONDS&&(n++,r=Math.max(r,e),i++)}}n>=g&&n/v.length>=_&&a.push({label:`Automated branch/PR workflow`,points:d.POINTS_BRANCH_PR_AUTOMATION,detail:`${n}/${v.length} branch creations followed by PRs within ${r}s`})}let b=s.filter(e=>e.type===`ForkEvent`);if(b.length>=d.FORKS_HIGH){let e=b.map(e=>(0,h.default)(e.created_at)).sort((e,t)=>e.valueOf()-t.valueOf()),t=t=>{let n=0,r=0;for(let i=0;i<e.length;i++){let a=e[i];for(;a&&a.diff(e[r],`hour`,!0)>t;)r++;let o=i-r+1;n=Math.max(n,o)}return n},n=t(24),r=t(48),i=t(72),o=null;if(n>=d.FORKS_SURGE_EXTREME_HIGH?o={label:`Extreme fork automation`,points:d.POINTS_FORK_SURGE_EXTREME_HIGH,detail:`${n} repositories forked in rapid succession (within 24 hours)`}:n>=d.FORKS_SURGE_SEVERE?o={label:`Severe fork surge`,points:d.POINTS_FORK_SURGE_SEVERE,detail:`${n} repositories forked in rapid succession (within 24 hours)`}:n>=d.FORKS_EXTREME?o={label:`Fork spike detected`,points:d.POINTS_FORK_SURGE,detail:`Burst of ${n} fork events in a single 24-hour window`}:n>=d.FORKS_HIGH?o={label:`Multiple forks`,points:d.POINTS_MULTIPLE_FORKS,detail:`${n} repositories forked in a single 24-hour window`}:r>=d.FORKS_SURGE_48H?o={label:`Multi-day fork surge`,points:d.POINTS_FORK_SURGE_48H,detail:`Concentrated burst: ${r} repositories forked over 2 days`}:i>=d.FORKS_SURGE_72H&&(o={label:`Severe multi-day fork surge`,points:d.POINTS_FORK_SURGE_72H,detail:`Rapid burst: ${i} repositories forked over 72 hours`}),o&&a.push(o),e.length>0&&!o){let t=e[0],n=e[e.length-1];if(t&&n){let e=Math.max(1,n.diff(t,`day`)),r=b.length/e;r>=d.FORKS_PER_DAY_HIGH&&e>=3&&a.push({label:`Sustained fork rate`,points:d.POINTS_FORKS_PER_DAY_HIGH,detail:`Average of ${r.toFixed(1)} forks per day over ${e} days (${b.length} total)`})}}let c=new Set;if(b.forEach(e=>{c.add(h.default.utc(e.created_at).format(`YYYY-MM-DD`))}),c.size>=d.CONSECUTIVE_FORK_DAYS&&!o){let e=Array.from(c).map(e=>(0,h.default)(e,`YYYY-MM-DD`)).sort((e,t)=>e.valueOf()-t.valueOf()),t=1,n=1;for(let r=1;r<e.length;r++){let i=e[r-1],a=e[r];a&&i&&a.diff(i,`day`)===1?(n++,t=Math.max(t,n)):n=1}if(t>=d.CONSECUTIVE_FORK_DAYS){let e=c.size;a.push({label:`Extended forking pattern`,points:d.POINTS_CONSECUTIVE_FORK_DAYS,detail:`Forking activity on ${e} days (${t} consecutive), ${b.length} repositories total`})}}let l=new Set(b.map(e=>e.repo?.name).filter(e=>e!==void 0));if(l.size>=d.FORK_REPO_DIVERSITY_HIGH&&!o){let t=``;if(e.length>1){let n=e[0],r=e[e.length-1].diff(n,`day`);t=r>0?` over ${r} days`:` in a short timeframe`}a.push({label:`Fork scatter pattern`,points:d.POINTS_FORK_DIVERSITY,detail:`Targeting ${l.size} different repositories${t}`})}if(b.length>=d.FORK_COMBINED_ACTIVITY_MIN&&s.length>=d.MIN_EVENTS_FOR_ANALYSIS){let e=new Set(b.map(e=>e.repo?.name).filter(e=>e!==void 0)),t=s.filter(e=>e.type===`CreateEvent`&&e.payload?.ref_type===`branch`).filter(t=>e.has(t.repo?.name||``)),n=s.filter(e=>e.type===`PullRequestEvent`&&e.payload?.action===`opened`).filter(t=>e.has(t.repo?.name||``));if(t.length>=d.FORK_COMBINED_BRANCHES&&n.length>=d.FORK_COMBINED_PRS){let e=b.map(e=>(0,h.default)(e.created_at)),r=t.map(e=>(0,h.default)(e.created_at)),i=n.map(e=>(0,h.default)(e.created_at)),o=h.default.max(e),s=h.default.min(r),c=h.default.min(i);if(o&&s&&c&&o.isBefore(s)&&s.isBefore(c)&&n.length<=t.length*2){let e=b.length+t.length+n.length;a.push({label:`Suspicious chained automations`,points:d.POINTS_FORK_COMBINED_ACTIVITY,detail:`${e} chained repository operations: ${b.length} forks followed by ${t.length} branches, then ${n.length} pull requests (based on available event history)`})}}}}if(p&&s.length>=d.MIN_EVENTS_FOR_ANALYSIS){let e=n.toLowerCase(),i=s.filter(e=>e.type===`PushEvent`);if(i.length>=d.MIN_EVENTS_FOR_ANALYSIS){let e=i.map(e=>(0,h.default)(e.created_at)).sort((e,t)=>e.valueOf()-t.valueOf()),t=0,n=0;for(let r=0;r<e.length;r++){let i=e[r];for(;i&&i.diff(e[n],`hour`,!0)>1;)n++;let a=r-n+1;t=Math.max(t,a)}t>=d.HOURLY_ACTIVITY_EXTREME?a.push({label:`Extreme commit burst`,points:d.POINTS_EXTREME_ACTIVITY_DENSITY,detail:`${t} commits within 1 hour`}):t>=d.HOURLY_ACTIVITY_HIGH&&a.push({label:`High commit burst`,points:d.POINTS_HIGH_ACTIVITY_DENSITY,detail:`${t} commits within 1 hour`});let r=0;for(let t=1;t<e.length;t++)e[t]!==void 0&&e[t-1]!==void 0&&e[t].diff(e[t-1],`second`)<=d.TIGHT_COMMIT_SECONDS&&r++;r>=d.TIGHT_COMMIT_THRESHOLD&&a.push({label:`High commit frequency`,points:d.POINTS_TIGHT_BURST,detail:`${r+1} commits within very short intervals`})}let o=s.filter(e=>e.type===`PullRequestEvent`&&e.payload?.action===`opened`);if(o.length>=d.MIN_EVENTS_FOR_ANALYSIS){let e=o.map(e=>(0,h.default)(e.created_at)),t=h.default.min(e),n=h.default.max(e);if(n){let e=Math.max(1,n.diff(t,`day`)),r=o.length/e;r>=d.ACTIVITY_DENSITY_EXTREME/2?a.push({label:`Very high PR volume`,points:d.POINTS_EXTREME_ACTIVITY_DENSITY+10,detail:`${o.length} PRs in ${e} day${e===1?``:`s`}`}):r>=d.ACTIVITY_DENSITY_HIGH/2&&a.push({label:`High PR volume`,points:d.POINTS_HIGH_ACTIVITY_DENSITY+5,detail:`${o.length} PRs in ${e} day${e===1?``:`s`}`})}}let c=new Set([`PushEvent`,`PullRequestEvent`]),m=s.filter(e=>e.type&&c.has(e.type)||e.type===`PullRequestReviewEvent`||e.type===`PullRequestReviewCommentEvent`),g=new Map;m.forEach(e=>{if(!e.created_at)return;let t=new Date(e.created_at),n=t.toISOString().slice(0,10);g.has(n)||g.set(n,[]),g.get(n).push(t)});let _=[];if(g.forEach((e,t)=>{let n=new Map;e.forEach(e=>{let t=e.getUTCHours();n.set(t,(n.get(t)||0)+1)});let r=n.size,i=u(Array.from(n.values()));r>=d.HOURS_PER_DAY_INHUMAN&&i>.8&&_.push(t)}),_.length>=d.CONSECUTIVE_INHUMAN_DAYS_EXTREME){_.sort();let e=1,t=1;for(let n=1;n<_.length;n++){let r=(0,h.default)(_[n-1]);(0,h.default)(_[n]).diff(r,`day`)===1?(e++,t=Math.max(t,e)):e=1}t>=d.CONSECUTIVE_INHUMAN_DAYS_EXTREME?a.push({label:`Extended daily coding`,points:d.POINTS_NONSTOP_ACTIVITY,detail:`${t} days in a row with ${d.HOURS_PER_DAY_INHUMAN}+ hours of coding`}):_.length>=d.FREQUENT_MARATHON_DAYS&&a.push({label:`Frequent long coding days`,points:d.POINTS_FREQUENT_MARATHON,detail:`${_.length} days with ${d.HOURS_PER_DAY_INHUMAN}+ hours of coding and uniform hourly distribution`})}if(p){let t=new Set(r.map(e=>e.repo?.name).filter(t=>t?t.split(`/`)[0]?.toLowerCase()!==e:!1));t.size>=d.REPO_SPREAD_EXTREME?a.push({label:`Highly distributed activity`,points:d.POINTS_EXTREME_REPO_SPREAD_YOUNG,detail:`Activity spread across ${t.size} external repositories`}):t.size>=d.REPO_SPREAD_HIGH&&a.push({label:`Distributed activity`,points:d.POINTS_WIDE_REPO_SPREAD_YOUNG,detail:`Activity spread across ${t.size} external repositories`})}let v=o.filter(t=>{let n=t.repo?.name?.split(`/`)[0]?.toLowerCase();return n&&n!==e}),y=(0,h.default)(),b=y.subtract(1,`week`),x=y.subtract(1,`day`),S=v.filter(e=>(0,h.default)(e.created_at).isAfter(b)),C=v.filter(e=>(0,h.default)(e.created_at).isAfter(x));if(C.length>=d.PRS_TODAY_EXTREME?a.push({label:`High PR volume in the past 24 hours`,points:d.POINTS_PR_BURST,detail:`${C.length} PRs to other repos in the last 24 hours`}):S.length>=d.PRS_WEEK_HIGH&&a.push({label:`High PR volume during last week`,points:d.POINTS_HIGH_PR_FREQUENCY,detail:`${S.length} PRs to other repos this week`}),v.length>=d.EXTERNAL_PRS_MIN&&t<d.PERSONAL_REPOS_LOW){let e=`${v.length} PRs to other repos, but only ${t} of their own`;t===0&&(e=`${v.length} PRs to other repos, none of their own`),a.push({label:`Primarily external contributions`,points:d.POINTS_PR_ONLY_CONTRIBUTOR,detail:e})}let w=l.length/s.length;!f&&w>=d.FOREIGN_RATIO_HIGH&&t<d.PERSONAL_REPOS_LOW&&a.push({label:`Mostly external activity`,points:d.POINTS_EXTERNAL_FOCUS,detail:`${Math.round(w*100)}% of activity on other people's repos`})}if(s.length>=d.MIN_EVENTS_FOR_ANALYSIS){let e=s.filter(e=>e.type===`PullRequestEvent`&&e.payload?.action===`opened`),t=(0,h.default)(),n=t.subtract(1,`day`),r=t.subtract(1,`week`),i=e.filter(e=>(0,h.default)(e.created_at).isAfter(n)),o=e.filter(e=>(0,h.default)(e.created_at).isAfter(r));if(i.length>=d.PRS_DAY_EXTREME&&a.push({label:`Extreme PR spam (daily)`,points:d.POINTS_PRS_DAY_EXTREME,detail:`${i.length} PRs in the last 24 hours`}),o.length>=d.PRS_WEEK_EXTREME?a.push({label:`Extreme PR spam (weekly)`,points:d.POINTS_PRS_WEEK_EXTREME,detail:`${o.length} PRs in the last 7 days`}):o.length>=d.PRS_WEEK_VERY_HIGH&&a.push({label:`Very high PR spam frequency`,points:d.POINTS_PRS_WEEK_VERY_HIGH,detail:`${o.length} PRs in the last 7 days`}),e.length>=d.PRS_SPAM_VOLUME&&!a.some(e=>e.label===`Extreme PR spam (daily)`||e.label===`Extreme PR spam (weekly)`||e.label===`Very high PR spam frequency`)){let t=new Set(e.map(e=>e.repo?.name).filter(e=>e!==void 0));if(t.size>=d.REPOS_SPAM_SPREAD){let n=e.map(e=>(0,h.default)(e.created_at)).sort((e,t)=>e.valueOf()-t.valueOf()),r=n[0],i=n[n.length-1],o=i?i.diff(r,`days`,!0):0,s=o/7,c=s>0?e.length/s:1/0,l=(0,h.default)().subtract(30,`days`),u=e.filter(e=>(0,h.default)(e.created_at).isAfter(l)).length,f=c>=d.PRS_SPAM_DENSITY_PER_WEEK,p=u>=d.PRS_SPAM_ROLLING_30DAYS;(f||p)&&a.push({label:`Distributed PR spam pattern`,points:d.POINTS_PR_SPAM_DISTRIBUTED,detail:`${e.length} PRs spread across ${t.size} different repositories${o>0?` (${c.toFixed(1)} PRs/week)`:``}`})}}}let x=a.reduce((e,t)=>e+=t.points,0),S=Math.max(0,100-x),C=`automation`;return S>=d.THRESHOLD_HUMAN?C=`organic`:S>=d.THRESHOLD_SUSPICIOUS&&(C=`mixed`),{score:S,classification:C,flags:a,profile:{age:c,repos:t}}}function y(e){return e?e===`organic`?{label:`Organic activity`,description:`No automation signals detected in the analyzed events.`}:e===`mixed`?{label:`Mixed activity`,description:`Activity patterns show a mix of organic and automated signals.`}:{label:`Automation signals`,description:`Activity patterns show signs of automation.`}:{label:`Analysis unavailable`,description:`Classification is not available for this account.`}}export{y as getClassificationDetails,v as identify,d as identityConfig};
|
package/package.json
CHANGED