157 points · by samizdis · 4y ago · 212 comments
https://github.com/SeanDaBlack/KelloggBot/blob/main/req.py
Edit: The code is not PERFECT as MANY people have picked it apart below.
But if I had to work with this code on a daily basis I would certainly not mind.
If you ever need a code review just post your code on hacker news and say it's well written....
https://www.selenium.dev/documentation/test_practices/encour...
public class Login {
public void testLogin() {
// fill login data on sign-in page
driver.findElement(By.name("user_name")).sendKeys("userName");
driver.findElement(By.name("password")).sendKeys("my supersecret password");
driver.findElement(By.name("sign-in")).click();
// verify h1 tag is "Hello userName" after login
driver.findElement(By.tagName("h1")).isDisplayed();
assertThat(driver.findElement(By.tagName("h1")).getText(), is("Hello userName"));
}
}Into this?:
public class SignInPage { protected WebDriver driver;
// <input name="user_name" type="text" value="">
private By usernameBy = By.name("user_name");
// <input name="password" type="password" value="">
private By passwordBy = By.name("password");
// <input name="sign_in" type="submit" value="SignIn">
private By signinBy = By.name("sign_in");
public SignInPage(WebDriver driver){
this.driver = driver;
}
/**
* Login as valid user
*
* @param userName
* @param password
* @return HomePage object
*/
public HomePage loginValidUser(String userName, String password) {
driver.findElement(usernameBy).sendKeys(userName);
driver.findElement(passwordBy).sendKeys(password);
driver.findElement(signinBy).click();
return new HomePage(driver);
}
}/** * Tests login feature */ public class TestLogin {
@Test
public void testLogin() {
SignInPage signInPage = new SignInPage(driver);
HomePage homePage = signInPage.loginValidUser("userName", "password");
assertThat(homePage.getMessageText(), is("Hello userName"));
}
}1. undescriptive variable names (eg. data2)
2. inconsistent formatting
3. copy pasted fragments everywhere
- Complicated flakey in-line xpaths '//*[@id="content"]/div/div[2]/div/div[1]/div[1]/div/div/button' ?!
- Time.sleep(x) is flakey, you should wait for the element to appear
- case first_name | last_name both uses a first_name() generator, should just be generate_name()
- Opening and closing the driver 10000 times
> 1. undescriptive variable names (eg. data2)
Doesn't matter. The file is 200 lines of code.
> 2. inconsistent formatting
That didn't make the code harder to read/follow.
> 3. copy pasted fragments everywhere
Meh. Really, I've seen code where everything that could be repeated was encapsulated in a function/method/class which was being used only once.
Right, I can follow the code just fine too, but OP's claim was
>well written, rather pretty code
Like you mentioned, the file is only 200 lines, so you can get away with quite a bit and still be understandable/maintainable, but that doesn't mean they're all "well written" or "rather pretty".
- Have you seen Carmack or Torvalds code?
> inconsistent formatting
- Needs more explanation? It's python, consistent formatting is enforced
> copy pasted fragments everywhere
- Nothing wrong with that AT ALL if you understand how it works. It's literally the fundamental premise of Github Co-pilot.
Which means it’s probably at least 80th percentile nowadays.
Additionally, there are plenty of red flags that any human reviewer would quickly pick up with these applications. The addresses don't exist. The random prior occupations it submits are rarely in line with what you'd expect for these positions. The name generator is pulling random first names for the last name as well. And the randomly generated email addresses contain names that don't match the name on application. So, the script will submit an application for "Susan Justin," a former Surgeon with the email address ronaldbrewer@example.com, at an address that doesn't exist.
I'm sure this is a nuisance for the HR analyst who's the first line of defense in reviewing applications. And they might've had to bring in someone with more technical/fraud skills to help weed out the fake applications, but it seems quite manageable.
[0] https://github.com/SeanDaBlack/KelloggBot/blob/main/src/resu...
Though they'll probably use that as an excuse to not provide insurance or pay a living wage... :(
That wouldn't be so hard to do, would it?
Edit: One thing I didn't think of was application source IP address. It's possible the ATS records that info when an app is submitted, so they could possibly delete bogus records that way but I'm no ATS expert and this is literally just my own conjecture.
I base this opinion off of ~6 year old data and experiences. The "best" horror story was an ATS that used client-side browser datetime without timezone support as their official timestamp record for various events.
If picketing IRL factories is allowed, what would the law be on DDOS of an online business by union members?
Even regular picketing sometimes gets sanctioned by the police. Just this October John Deere picketers were sanctioned for blocking a gate. [1]
[1] https://nptelegraph.com/business/deere-wins-injunction-again...
>Even regular picketing sometimes gets sanctioned by the police. Just this October John Deere picketers were sanctioned for blocking a gate. [1]
Did those actions get put down because it was labor action, or was it because those actions were not acceptable? ie. if I said [unpopular thing] online, and a bunch of protesters showed up to my house and blocked my driveway, preventing me from going to work, would it be reasonable for the police to disperse those protesters? would it be reasonable for me to get an injunction against those protesters to prevent them from doing it again?
Not sure how to respond to your example because its a different situation? Do you think workers are just angry in the same way the mob outside of your house is? Or do you maybe think they are just trying to survive in this world?
I'm pretty sure union/striking isn't a valid excuse to violate laws, and that "picketing IRL factories" doesn't violate any laws (ie. they do in on the sidewalk/public roads).
A coal company in Alabama recently won a restraining order that fully prohibited a picket line at their mine: https://www.msn.com/en-us/news/us/judge-issues-restraining-o...
Manually submitting 50 job applications with false information also does not violate any laws that I am aware of.
The focus then becomes on automation. But if I automate the job application process at 1 application/day, that's not illegal. So it becomes a balancing act between how fast I am automating, and how shoddily designed the application system is.
I don't think it's as cut and dry as "this is illegal" or not.
(IANAL, working from American perspective)
OTOH, if we're going to consider "sharing too much information to an individual for them to process it" to be a DDOS, there are a whole bunch of Terms of Service that will need to be rewritten. So maybe this is a good idea...
(edit ... link: https://www.wired.com/2010/01/guilty-plea-in-scientology-ddo...)
The DDOS would fall under (among, I'm sure, other laws) the CFAA and could be a felony if someone wanted to pursue it.
https://github.com/SeanDaBlack/KelloggBot looks like its still up for now
yea... why would they use their real name haha
The obvious reading is that they legitimately saw no problem initially and then realized later that it was legally questionable and yanked it.
Turns out those hunches are pretty reliable, who woulda thunk it.
it's the invocation of it that would be, right?
I'm strongly against the idea of using weaponized computer code to disrupt their hiring operations and flooding. Sounds like it is probably illegal.
I guess I am new to Ycombinator, is this type of thread the norm here? Seems pretty sketchy and I would say this is probably the lowest quality thread I've seen on this entire network this week.
As far as I am concerned, anyone has the right to disagree. The company disagreed on terms with some potential hires who wanted a better job offer and has a right to look elsewhere for employees. There is nothing more to it than that.
The community guidelines are an attempt at saying please be decent so as to foster a more desirable community. Think about it. That is why you are here and not reddit.
>>Be kind. Don't be snarky. Have curious conversation; don't cross-examine. Please don't fulminate. Please don't sneer, including at the rest of the community.
>>Comments should get more thoughtful and substantive, not less, as a topic gets more divisive.
>>Eschew flamebait. Avoid unrelated controversies and generic tangents.
For example, if a tech union offered networking opportunities, resume-building help, internships, and access to companies looking for employees, I would join.
Typically engineers for example will join something like IEEE, ASME, or AIChE.
The reason for this difference is that in the case of well paid, in demand professions like engineering, it is typically a better strategy to just have enough money stored to to bridge the gap and move on to another job quickly if your employer is shitty.
Laborers don't typically have those privileges, so they form organizations that help them defend their current jobs.
And I would add, banning employers that use anti-labor tactics... Bring in "Scabs" ? Lose access to the best people until restitution is made.
Edit: I also think incentives can be better aligned by bringing more equity or corporate performance pay eg: you get $20 an hour base pay, but $15 an hour is actually in company stock or bonuses on profit etc.
IIRC westjet (canadian airline) had a lot of success making every single employee have equity pay ("be an owner/shareholder") ...
If you look at /r/antiwork you’ll realize that these demands are more and more moving goalposts. I don’t understand that subreddit. They think jobs grow on trees.
Why is this relevant? Does being labeled as a "striker" give you additional legal rights that you wouldn't otherwise have?
>It's no different than mailing in a bunch of applications, it's just digital instead. They aren't burning down the offices
"not burning down offices" seems like a pretty low bar for acceptable conduct. that doesn't mean their behavior is legal. The obvious analogy would be: would it be legal to spam a pizza restaurant with fake orders? Or spamming a doctor/hospital with fake appointments? Or spamming police departments with fake tips?
Actually, yes.
For instance, if you are an employee who is striking, you have the right to use racial slurs to abuse and harass employees who are not striking, without being fired for use of those remarks. See Cooper Tire & Rubber Co. v. NLRB. (Remarks included: "Go back to Africa, you bunch of f--- losers!", statements regarding fried chicken, watermelon, etc.)
There are a variety of other rights conferred by law.
Spamming a police department with fake tips is specifically illegal (making a false police report and/or obstruction of justice and/or USC 1001). I'm not sure about fake appointments for a hospital, that seems the most unclear of the cases you've listed.
A bunch of trump supports went to Washington to "protest" - not turning out very well for them. Similarly with many other protests (BLM etc etc), folks getting picked up breaking windows, stealing, burning down buildings etc - they don't get off free because it's a protest or there is not something in the law that makes calling something illegal a protest legal.
No one made that claim.
"Rutgers University professor Todd Vachon, who teaches classes about labor relations, said he's not sure the company will be able to hire enough workers to replace the ones who are out on strike in the current economy, and Kellogg's may have a hard time finding people willing to cross a picket line."
https://www.cbsnews.com/news/kelloggs-will-replace-striking-...
Your metaphor to police corruption is also why "context" is an important thing. In that case people would actually get hurt, in this case a company loses money. They are different scenarios completely.
Logic is not part of the CFAA.
However, Kellogg's is soliciting job applications from the public. Automating the submission of a single application is clearly legal, but submitting many with the intention of overloading digital systems is clearly illegal.
IMO, this case is legally ambiguous because they are using a digital system to overwhelm a human system.
The public is 'authorized' to submit one application, so it's hard to say submitting many applications is unauthorized, unless done with intent of crashing servers.
Yeah fuck it if this is bad, then I definitely don't want to be good.
By what principle does a group of striking employees have some intrinsic God-given right (or right conferred by some other source of truth, outside the law) to sabotage the company that they are protesting? Is the company their property, that they have veto power over hiring? Is the labor force their property? If there is some property-like interest that grants these rights, then under what circumstances would that interest became their property rather than the original worker's? Is it strictly first come, first serve? Is there a vesting period during which this right accrues? Are the striking employees as a group to be considered a form of government, that they may regulate hiring and firing? What elevates this right or interest over other cherished principles, such as free association? Or do the strikers simply wish to subjugate such principles to serve their own self-interest?
I believe that you propose mob rule. It is no surprise, then, that you are in conflict with a nation ruled by laws, rather than by mobs and strongmen.
I did encounter a password field bad enough that password management software generated passwords aren’t allowed but “Password12345” is.
Presumably it will soon gain one, if it hasn't already.
They have a browser extension too, I guess it detects the displayed captcha and submits it to the API
Finally repercussions for the sites not updating their recaptcha versions and annoying everyone with v2
This is not advice, just observation.
I kind of see the point that you're trying to make, but I'm sure you understand that not everyone is in the same position to pick and choose jobs that the majority of HN find themselves in. Often when someone takes a job, it's because they need a job in order to live.
It's pretty shitty of you to suggest that that individual should be barred from future employment because they had to take a job that was available, even if the reason it was available is disagreeable.
We're currently living in one of those rare times where there are a lot of non-questionable jobs going unfilled, and employers are a little uncomfortable with the number of job vacancies. So, if you have to take a job, there are currently plenty out there that keep your hands clean of strike-busting.
Sure, but "ethically questionable jobs" is a pretty massive spectrum, and I'm not sure that I would agree that "making cereal during a labor dispute" meets the line of "to unethical for me" for the majority of people.
> So, if you have to take a job, there are currently plenty out there that keep your hands clean of strike-busting.
So is strike-busting the only place you draw the line? What about having to take a job at Hobby-Lobby? Or Chick-fil-a? Amazon has some some pretty sleezy stuff, so you don't want to support them. Walmart employees often depend on food stamps, and you should keep your hands clean of supporting a company that treats it's employees so poorly.
There are tons of jobs that you could take in order to keep food on your table that aren't Kellogg, or Hobby-Lobby, or Chick-fil-a, or Amazon, or Walmart.
If you keep digging, you'll quickly run out of "non-questionable" jobs. You are definitely welcome to blame the employer for their actions, policies, and decisions, but it's not fair to say "Well Jonny over there once worked at a company that I have an objection to, so he should never be allowed to have a job again!"
I don't believe that anyone taking these positions are doing it in order to advance their career.
> will probably leave them worse off
Worse than homeless, starving, and possibly dead?
The suggestion isn't necessarily moralistic. It's just a way to bring about collective action. In a strike, workers are sacrificing their immediate benefit for greater benefit in the long term. Workers generally win concessions through collective action. It didn't work here because unions in the U.S. are weak. If workers were better organized, they would have stood a better chance. Well organized labor benefits society as a whole; just look at the Nordic countries.
This is literally in reply to the company firing all the workers who used collective bargaining.
The collective bargaining I was suggesting was to talk with your own companies which have a business relationship to Kellog.
Work in a hotel that has minicereal boxes? Get with purchasing to stock a different brand. Work in a grocery? Ask the owners to stock a different brand on a public forum.
See Kellogg flakes at a friend's or family's house? Ask them politely not to support union busting.
Daily call one local business until they agree not to stock Kelloggs.
Collective bargaining might help, but even Kellogg's union isn't capable of doing much -- only one factory is striking. Why would an unaffiliated union spend huge resources on helping Kellogg workers rather than its own members?
Because otherwise unions will target them, in turn, with worker's actions. That is how union power works in places that have real, functioning unions.
Unions protect workers against exploitations, and that is good for everyone.
Heh, reminds me of a song: https://www.youtube.com/watch?v=Ww5l5BAJ39A
Also, both Kellogg's and Post make shredded wheat and Raisin Bran.